MCPcopy Index your code
hub / github.com/pgadmin-org/pgadmin4 / parseApiError

Function parseApiError

web/pgadmin/static/js/api_instance.js:26–58  ·  view source on GitHub ↗
(error, withData=false)

Source from the content-addressed store, hash-verified

24}
25
26export function parseApiError(error, withData=false) {
27 if (error.response) {
28 // The request was made and the server responded with a status code
29 // that falls out of the range of 2xx
30 if(error.response.headers['content-type'] == 'application/json') {
31 let err_resp_data = error.response.data;
32 if (err_resp_data.response != undefined && Array.isArray(err_resp_data.response.errors)) {
33 return err_resp_data.response.errors[0];
34 } else {
35 let errormsg = err_resp_data.errormsg;
36 let data = error.response.data.data;
37 // If we want to use data which came with error set withData
38 // flag to true.
39 return withData ? {errormsg, data} : errormsg;
40 }
41 } else {
42 return error.response.statusText;
43 }
44 } else if (error.request) {
45 // The request was made but no response was received
46 // `error.request` is an instance of XMLHttpRequest in the browser and an instance of
47 // http.ClientRequest in node.js
48 return gettext('Connection to pgAdmin server has been lost');
49 } else if(error.message) {
50 // Something happened in setting up the request that triggered an Error
51 return error.message;
52 } else if(error.errormsg) {
53 // Received response JSON in socket handle
54 return error.errormsg;
55 } else {
56 return error;
57 }
58}
59
60export function callFetch(url, options, headers={}) {
61 return fetch(url, {

Callers 15

connect_to_serverFunction · 0.90
connectFunction · 0.90
startDebuggingFunction · 0.90
onSearchFunction · 0.90
typeOptionsFunction · 0.90
handleAxiosCatchMethod · 0.90
deleteRowFunction · 0.90
onDeleteClickFunction · 0.90
updateListFunction · 0.90
initializeFunction · 0.90
onSaveClickFunction · 0.90
onSaveClickFunction · 0.90

Calls 1

gettextFunction · 0.85

Tested by

no test coverage detected