From 80beb0c054962a67e612d0239abb4c00d1bf5ca5 Mon Sep 17 00:00:00 2001 From: Anwesha Chatterjee <@boeing.com.au> Date: Thu, 22 Jun 2017 15:59:53 +1000 Subject: [PATCH] if adventure by the specified name not found, then throw error --- index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/index.js b/index.js index bb4eae4..6d0118b 100644 --- a/index.js +++ b/index.js @@ -242,6 +242,12 @@ Shop.prototype.fail = function (name, p) { Shop.prototype.select = function (name) { var adv = this.find(name); + if (!adv) { + return this._error( + 'An adventure with this name does not exist. ' + + 'Select an adventure from the menu.' + ); + } this.state.current = name; this.save('current');