Skip to content

Commit

Permalink
Merge pull request #660 from ianbjorndilling/bugfix-536
Browse files Browse the repository at this point in the history
Custom deletion hook error messages: issue #536
  • Loading branch information
JedWatson committed Oct 4, 2014
2 parents 39943d5 + 66f0bd7 commit c5006b3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions public/js/views/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,9 @@ jQuery(function($) {
err = err.responseJSON;
}
var errorMessage = 'There was an error deleting the ' + Keystone.list.singular.toLowerCase() + '.';
if (err && err.error) {
errorMessage += ' ( error: ' + err.error + ')';
var errorDetail = err ? err.detail || err.error : '';
if (errorDetail) {
errorMessage += ' ( error: ' + errorDetail + ')';
}
alert(errorMessage);
$row.removeClass('delete-inprogress');
Expand Down
2 changes: 1 addition & 1 deletion routes/api/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ exports = module.exports = function(req, res) {
console.log(err);
}
res.status(500);
sendResponse({ error: key || 'error', detail: err });
sendResponse({ error: key || 'error', detail: err ? err.message : '' });
};

switch (req.params.action) {
Expand Down
2 changes: 1 addition & 1 deletion routes/views/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ exports = module.exports = function(req, res) {
if (err) {
console.log('Error deleting ' + req.list.singular);
console.log(err);
req.flash('error', 'There was an error deleting ' + req.list.singular + ' (logged to console)');
req.flash('error', 'Error deleting the ' + req.list.singular + ': ' + err.message);
} else {
req.flash('success', req.list.singular + ' deleted successfully.');
}
Expand Down

0 comments on commit c5006b3

Please sign in to comment.