Skip to content

Instantly share code, notes, and snippets.

@shindakun
Created June 9, 2014 20:42
Show Gist options
  • Save shindakun/4fbdcc581d0a6dd9da03 to your computer and use it in GitHub Desktop.
Save shindakun/4fbdcc581d0a6dd9da03 to your computer and use it in GitHub Desktop.
showerror
showAPIError: function (resp, defaultErrorText) {
defaultErrorText = defaultErrorText || 'There was a problem on the server, please try again.';
if (resp && resp.jqXHR && resp.jqXHR.responseJSON && resp.jqXHR.responseJSON.error) {
this.showError(resp.jqXHR.responseJSON.error);
} else if (resp && resp.jqXHR && resp.jqXHR.responseJSON && resp.jqXHR.responseJSON.errors) {
for (var i = 0; i < resp.jqXHR.responseJSON.errors.length; i += 1) {
this.showError(resp.jqXHR.responseJSON.errors[i].message);
}
} else {
this.showError(defaultErrorText);
}
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment