From b8145154ba66b0a27a68aaa132557fcc0cf0bcf7 Mon Sep 17 00:00:00 2001 From: Joseph Schmitt Date: Sun, 27 Mar 2016 18:02:00 -0400 Subject: [PATCH] Add exception handling --- lib/index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/index.js b/lib/index.js index 0fe3382..7c5d90d 100644 --- a/lib/index.js +++ b/lib/index.js @@ -12,4 +12,11 @@ app.intent('AMAZON.YesIntent', handlers.handleYesIntent); app.intent('AMAZON.NoIntent', handlers.handleNoIntent); app.intent('AMAZON.CancelIntent', handlers.handleCancelIntent); +app.post = function(request, response, type, exception) { + if (exception) { + // Always turn an exception into a successful response + response.clear().say('An error occured: ' + exception).send(); + } +}; + module.exports = app;