shortcut: explicit exception message

In the function remove_shortcut, if the action failed, it used to
throw an 'implementation oriented' exception message:
> throws('try to delete non-leaf')
This is not a good message for the user who wants to mess with the
shortcuts.

The solution is to leave this 'implementation oriented' exception message
and add a try-catch bloc above that catches this message and throws
a new, frendliest, exception message.
I came up with this:
> throws('try to remove non-existing shortcut')

* notebook/static/base/js/keyboard.js: (remove_shortcut) add try-catch.

Signed-off-by: Nicolas Barray <nbarray@gmail.com>
Nicolas Barray 11 years ago
parent e0bb6e6f2f
commit 94d13ef899

@ -385,10 +385,19 @@ define([
if( typeof(shortcut) === 'string'){
shortcut = shortcut.split(',');
}
this._remove_leaf(shortcut, this._shortcuts);
if (!suppress_help_update) {
/*
* The shortcut error should be explicit here, because it will be
* seen by users.
*/
try
{
this._remove_leaf(shortcut, this._shortcuts);
if (!suppress_help_update) {
// update the keyboard shortcuts notebook help
this.events.trigger('rebuild.QuickHelp');
}
} catch (ex) {
throw ('try to remove non-existing shortcut');
}
};

Loading…
Cancel
Save