mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Standardise the error handling for parsing of JSON response messages from the server. Fixes #3238
This commit is contained in:
@@ -209,15 +209,8 @@ define('pgadmin.node.cast', [
|
||||
},
|
||||
|
||||
// On failure show error appropriate error message to user
|
||||
error: function(xhr) {
|
||||
try {
|
||||
var err = $.parseJSON(xhr.responseText);
|
||||
if (err.success == 0) {
|
||||
alertify.error(err.errormsg);
|
||||
}
|
||||
} catch (e) {
|
||||
// Do nothing
|
||||
}
|
||||
error: function(xhr, status, error) {
|
||||
alertify.pgRespErrorNotify(xhr, error);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -163,15 +163,8 @@ define('pgadmin.node.synonym', [
|
||||
},
|
||||
|
||||
// On failure show error appropriate error message to user
|
||||
error: function(xhr) {
|
||||
try {
|
||||
var err = $.parseJSON(xhr.responseText);
|
||||
if (err.success == 0) {
|
||||
alertify.error(err.errormsg);
|
||||
}
|
||||
} catch (e) {
|
||||
// Ignore
|
||||
}
|
||||
error: function(xhr, status, error) {
|
||||
alertify.pgRespErrorNotify(xhr, error);
|
||||
},
|
||||
});
|
||||
return res;
|
||||
|
||||
@@ -73,15 +73,8 @@ define('pgadmin.node.check_constraint', [
|
||||
setTimeout(function() {t.select(i);}, 100);
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
try {
|
||||
var err = $.parseJSON(xhr.responseText);
|
||||
if (err.success == 0) {
|
||||
alertify.error(err.errormsg);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e.stack || e);
|
||||
}
|
||||
error: function(xhr, status, error) {
|
||||
alertify.pgRespErrorNotify(xhr, error);
|
||||
t.unload(i);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -665,15 +665,8 @@ define('pgadmin.node.foreign_key', [
|
||||
setTimeout(function() {t.select(i);}, 100);
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
try {
|
||||
var err = $.parseJSON(xhr.responseText);
|
||||
if (err.success == 0) {
|
||||
Alertify.error(err.errormsg);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e.stack || e);
|
||||
}
|
||||
error: function(xhr, status, error) {
|
||||
Alertify.pgRespErrorNotify(xhr, error);
|
||||
t.unload(i);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -174,15 +174,8 @@ function(
|
||||
}, 10);
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
try {
|
||||
var err = $.parseJSON(xhr.responseText);
|
||||
if (err.success == 0) {
|
||||
Alertify.error(err.errormsg);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e.stack || e);
|
||||
}
|
||||
error: function(xhr, status, error) {
|
||||
Alertify.pgRespErrorNotify(xhr, error);
|
||||
t.unload(i);
|
||||
},
|
||||
});
|
||||
@@ -233,15 +226,8 @@ function(
|
||||
}, 10);
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
try {
|
||||
var err = $.parseJSON(xhr.responseText);
|
||||
if (err.success == 0) {
|
||||
Alertify.error(err.errormsg);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e.stack || e);
|
||||
}
|
||||
error: function(xhr, status, error) {
|
||||
Alertify.pgRespErrorNotify(xhr, error);
|
||||
t.unload(i);
|
||||
},
|
||||
});
|
||||
@@ -283,15 +269,8 @@ function(
|
||||
}, 10);
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
try {
|
||||
var err = $.parseJSON(xhr.responseText);
|
||||
if (err.success == 0) {
|
||||
Alertify.error(err.errormsg);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e.stack || e);
|
||||
}
|
||||
error: function(xhr, status, error) {
|
||||
Alertify.pgRespErrorNotify(xhr, error);
|
||||
t.unload(i);
|
||||
},
|
||||
});
|
||||
@@ -335,15 +314,8 @@ function(
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
try {
|
||||
var err = $.parseJSON(xhr.responseText);
|
||||
if (err.success == 0) {
|
||||
Alertify.error(err.errormsg);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e.stack || e);
|
||||
}
|
||||
error: function(xhr, status, error) {
|
||||
Alertify.pgRespErrorNotify(xhr, error);
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -941,9 +913,8 @@ function(
|
||||
);
|
||||
}
|
||||
},
|
||||
error: function(e) {
|
||||
var errmsg = $.parseJSON(e.responseText);
|
||||
Alertify.alert(gettext('Error fetching tables to be attached'), errmsg.errormsg);
|
||||
error: function(xhr, status, error) {
|
||||
Alertify.pgRespErrorNotify(xhr, error, gettext('Error fetching tables to be attached'));
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -153,15 +153,8 @@ define('pgadmin.node.table', [
|
||||
}, 10);
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
try {
|
||||
var err = $.parseJSON(xhr.responseText);
|
||||
if (err.success == 0) {
|
||||
Alertify.error(err.errormsg);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e.stack || e);
|
||||
}
|
||||
error: function(xhr, status, error) {
|
||||
Alertify.pgRespErrorNotify(xhr, error);
|
||||
t.unload(i);
|
||||
},
|
||||
});
|
||||
@@ -212,15 +205,8 @@ define('pgadmin.node.table', [
|
||||
}, 10);
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
try {
|
||||
var err = $.parseJSON(xhr.responseText);
|
||||
if (err.success == 0) {
|
||||
Alertify.error(err.errormsg);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e.stack || e);
|
||||
}
|
||||
error: function(xhr, status, error) {
|
||||
Alertify.pgRespErrorNotify(xhr, error);
|
||||
t.unload(i);
|
||||
},
|
||||
});
|
||||
@@ -262,15 +248,8 @@ define('pgadmin.node.table', [
|
||||
}, 10);
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
try {
|
||||
var err = $.parseJSON(xhr.responseText);
|
||||
if (err.success == 0) {
|
||||
Alertify.error(err.errormsg);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e.stack || e);
|
||||
}
|
||||
error: function(xhr, status, error) {
|
||||
Alertify.pgRespErrorNotify(xhr, error);
|
||||
t.unload(i);
|
||||
},
|
||||
});
|
||||
@@ -302,15 +281,8 @@ define('pgadmin.node.table', [
|
||||
t.select(i);
|
||||
}, 10);
|
||||
},
|
||||
error: function(xhr) {
|
||||
try {
|
||||
var err = $.parseJSON(xhr.responseText);
|
||||
if (err.success == 0) {
|
||||
Alertify.error(err.errormsg);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e.stack || e);
|
||||
}
|
||||
error: function(xhr, status, error) {
|
||||
Alertify.pgRespErrorNotify(xhr, error);
|
||||
t.unload(i);
|
||||
},
|
||||
});
|
||||
@@ -1047,9 +1019,8 @@ define('pgadmin.node.table', [
|
||||
);
|
||||
}
|
||||
},
|
||||
error: function(e) {
|
||||
var errmsg = $.parseJSON(e.responseText);
|
||||
Alertify.alert(gettext('Error fetching tables to be attached'), errmsg.errormsg);
|
||||
error: function(xhr, status, error) {
|
||||
Alertify.pgRespErrorNotify(xhr, error);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -130,15 +130,8 @@ define('pgadmin.node.trigger', [
|
||||
}, 10);
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
try {
|
||||
var err = $.parseJSON(xhr.responseText);
|
||||
if (err.success == 0) {
|
||||
alertify.error(err.errormsg);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e.stack || e);
|
||||
}
|
||||
error: function(xhr, status, error) {
|
||||
alertify.pgRespErrorNotify(xhr, error);
|
||||
t.unload(i);
|
||||
},
|
||||
});
|
||||
@@ -175,15 +168,8 @@ define('pgadmin.node.trigger', [
|
||||
}, 10);
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
try {
|
||||
var err = $.parseJSON(xhr.responseText);
|
||||
if (err.success == 0) {
|
||||
alertify.error(err.errormsg);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e.stack || e);
|
||||
}
|
||||
error: function(xhr, status, error) {
|
||||
alertify.pgRespErrorNotify(xhr, error, gettext('Disable trigger failed'));
|
||||
t.unload(i);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -300,9 +300,8 @@ define('pgadmin.node.mview', [
|
||||
);
|
||||
}
|
||||
},
|
||||
error: function(e) {
|
||||
var errmsg = $.parseJSON(e.responseText);
|
||||
Alertify.alert(gettext('Error refreshing view'), errmsg.errormsg);
|
||||
error: function(xhr, status, error) {
|
||||
Alertify.pgRespErrorNotify(xhr, error, gettext('Error refreshing view'));
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -208,15 +208,8 @@ define('pgadmin.node.database', [
|
||||
t.unload(i);
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
try {
|
||||
var err = $.parseJSON(xhr.responseText);
|
||||
if (err.success == 0) {
|
||||
Alertify.error(err.errormsg);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e.stack || e);
|
||||
}
|
||||
error: function(xhr, status, error) {
|
||||
Alertify.pgRespErrorNotify(xhr, error);
|
||||
t.unload(i);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -175,24 +175,8 @@ define('pgadmin.node.pga_job', [
|
||||
// 'pgagent.pga_job' table updated with current time to run the job
|
||||
// now.
|
||||
success: function() { t.unload(i); },
|
||||
error: function(xhr) {
|
||||
var error_msg = gettext('Unable to run pgagent job.');
|
||||
if (xhr.readyState == 0) {
|
||||
alertify.error(
|
||||
gettext('Not connected to the server or the connection to the server has been closed.')
|
||||
);
|
||||
}
|
||||
else {
|
||||
if (_.isUndefined(xhr.responseText)) {
|
||||
alertify.error(error_msg);
|
||||
}
|
||||
else {
|
||||
var err = $.parseJSON(xhr.responseText);
|
||||
if (err.success == 0) {
|
||||
alertify.error(err.errormsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
error: function(xhr, status, error) {
|
||||
alertify.pgRespErrorNotify(xhr, error);
|
||||
t.unload(i);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -217,15 +217,8 @@ define('pgadmin.node.server', [
|
||||
t.unload(i);
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
try {
|
||||
var err = $.parseJSON(xhr.responseText);
|
||||
if (err.success == 0) {
|
||||
Alertify.error(err.errormsg);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e.stack || e);
|
||||
}
|
||||
error: function(xhr, status, error) {
|
||||
Alertify.pgRespErrorNotify(xhr, error);
|
||||
t.unload(i);
|
||||
},
|
||||
});
|
||||
@@ -299,15 +292,8 @@ define('pgadmin.node.server', [
|
||||
Alertify.error(res.data.result);
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
try {
|
||||
var err = $.parseJSON(xhr.responseText);
|
||||
if (err.success == 0) {
|
||||
Alertify.error(err.errormsg);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e.stack || e);
|
||||
}
|
||||
error: function(xhr, status, error) {
|
||||
Alertify.pgRespErrorNotify(xhr, error);
|
||||
t.unload(i);
|
||||
},
|
||||
});
|
||||
@@ -342,15 +328,8 @@ define('pgadmin.node.server', [
|
||||
success: function(res) {
|
||||
Alertify.success(res.data.result, 10);
|
||||
},
|
||||
error: function(xhr) {
|
||||
try {
|
||||
var err = $.parseJSON(xhr.responseText);
|
||||
if (err.success == 0) {
|
||||
Alertify.error(err.errormsg, 10);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e.stack || e);
|
||||
}
|
||||
error: function(xhr, status, error) {
|
||||
Alertify.pgRespErrorNotify(xhr, error);
|
||||
t.unload(i);
|
||||
},
|
||||
});
|
||||
@@ -520,15 +499,8 @@ define('pgadmin.node.server', [
|
||||
Alertify.error(res.errormsg);
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
try {
|
||||
var err = $.parseJSON(xhr.responseText);
|
||||
if (err.success == 0) {
|
||||
Alertify.error(err.errormsg);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e.stack || e);
|
||||
}
|
||||
error: function(xhr, status, error) {
|
||||
Alertify.pgRespErrorNotify(xhr, error);
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -547,15 +519,8 @@ define('pgadmin.node.server', [
|
||||
}
|
||||
Alertify.changeServerPassword(d).resizeTo('40%','52%');
|
||||
},
|
||||
error: function(xhr) {
|
||||
try {
|
||||
var err = $.parseJSON(xhr.responseText);
|
||||
if (err.success == 0) {
|
||||
Alertify.error(err.errormsg);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e.stack || e);
|
||||
}
|
||||
error: function(xhr, status, error) {
|
||||
Alertify.pgRespErrorNotify(xhr, error);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -590,15 +555,8 @@ define('pgadmin.node.server', [
|
||||
}, 10);
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
try {
|
||||
var err = $.parseJSON(xhr.responseText);
|
||||
if (err.success == 0) {
|
||||
Alertify.error(err.errormsg);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e.stack || e);
|
||||
}
|
||||
error: function(xhr, status, error) {
|
||||
Alertify.pgRespErrorNotify(xhr, error);
|
||||
t.unload(i);
|
||||
},
|
||||
});
|
||||
@@ -632,15 +590,8 @@ define('pgadmin.node.server', [
|
||||
}, 10);
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
try {
|
||||
var err = $.parseJSON(xhr.responseText);
|
||||
if (err.success == 0) {
|
||||
Alertify.error(err.errormsg);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e.stack || e);
|
||||
}
|
||||
error: function(xhr, status, error) {
|
||||
Alertify.pgRespErrorNotify(xhr, error);
|
||||
t.unload(i);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -285,15 +285,8 @@ define('pgadmin.node.tablespace', [
|
||||
Alertify.error(res.errormsg);
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
try {
|
||||
var err = $.parseJSON(xhr.responseText);
|
||||
if (err.success == 0) {
|
||||
Alertify.error(err.errormsg);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e.stack || e);
|
||||
}
|
||||
error: function(xhr, status, error) {
|
||||
Alertify.pgRespErrorNotify(xhr, error);
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user