mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Change error message response
closes #2643 - added error type - added error property for validations - wrapped errors in an array - returns multiple errors for validation - updated tests and admin
This commit is contained in:
parent
2d95159a6f
commit
fc667832c3
2 changed files with 11 additions and 4 deletions
|
@ -96,7 +96,14 @@
|
|||
if (request.status !== 200) {
|
||||
try {
|
||||
// Try to parse out the error, or default to "Unknown"
|
||||
message = request.responseJSON.error || "Unknown Error";
|
||||
if (request.responseJSON.errors && _.isArray(request.responseJSON.errors)) {
|
||||
message = '';
|
||||
_.each(request.responseJSON.errors, function (errorItem) {
|
||||
message += '<br/>' + errorItem.message;
|
||||
});
|
||||
} else {
|
||||
message = request.responseJSON.error || "Unknown Error";
|
||||
}
|
||||
} catch (e) {
|
||||
msgDetail = request.status ? request.status + " - " + request.statusText : "Server was not available";
|
||||
message = "The server returned an error (" + msgDetail + ").";
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
error: function (response) {
|
||||
$('#startupload').text('Import');
|
||||
var responseJSON = response.responseJSON,
|
||||
message = responseJSON && responseJSON.error ? responseJSON.error : 'unknown';
|
||||
message = responseJSON && responseJSON.errors[0].message ? responseJSON.errors[0].message : 'unknown';
|
||||
Ghost.notifications.addItem({
|
||||
type: 'error',
|
||||
message: ['A problem was encountered while importing new content to your blog. Error: ', message].join(''),
|
||||
|
@ -123,7 +123,7 @@
|
|||
},
|
||||
error: function onError(response) {
|
||||
var responseText = JSON.parse(response.responseText),
|
||||
message = responseText && responseText.error ? responseText.error : 'unknown';
|
||||
message = responseText && responseText.errors[0].message ? responseText.errors[0].message : 'unknown';
|
||||
Ghost.notifications.addItem({
|
||||
type: 'error',
|
||||
message: ['A problem was encountered while deleting content from your blog. Error: ', message].join(''),
|
||||
|
@ -175,7 +175,7 @@
|
|||
},
|
||||
error: function onError(response) {
|
||||
var responseText = JSON.parse(response.responseText),
|
||||
message = responseText && responseText.error ? responseText.error : 'unknown';
|
||||
message = responseText && responseText.errors[0].message ? responseText.errors[0].message : 'unknown';
|
||||
Ghost.notifications.addItem({
|
||||
type: 'error',
|
||||
message: ['A problem was encountered while sending the test email: ', message].join(''),
|
||||
|
|
Loading…
Add table
Reference in a new issue