add error for non-existent commands
Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
This commit is contained in:
parent
17b75cb64b
commit
593a37bdfc
1 changed files with 7 additions and 0 deletions
|
@ -4,6 +4,9 @@
|
|||
|
||||
const _commands_events = new Observer();
|
||||
|
||||
/** CommandNonExistentError */
|
||||
class CommandNonExistentError extends Error {}
|
||||
|
||||
/** Global Commands Object */
|
||||
const commands = makeReadOnly(
|
||||
{
|
||||
|
@ -150,6 +153,10 @@ const commands = makeReadOnly(
|
|||
* @param {any} options The options to be sent to the command to be run
|
||||
*/
|
||||
runCommand(name, title, options = null) {
|
||||
if (!this._types[name])
|
||||
throw CommandNonExistentError(
|
||||
`[commands] Command '${name}' does not exist`
|
||||
);
|
||||
this._types[name](title, options);
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue