question

Andrea Bucaletti avatar image
Andrea Bucaletti asked

Empty error object

Hello everyone,

so I created a custom skill with the default handlers and stuff, I'm now using local debugger and testing my code. Sometimes of course I make some mistakes and I call some methods on undefined or null objects. I would expect to get an error with the stack trace like usual, but the ErrorHandler (the one that comes when you create the skill) gives me back an empty error object, so everytime I have to put a breakpoint and find the exact line of code that is causing the error.

Any ideas?

Thanks

debuggingcustom skill
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Andy Whitworth avatar image
Andy Whitworth answered

Hi,

Not sure what language you're using, but in node I use the following error handler:


const ErrorHandler = {
  canHandle() {
    return true;
  },
  handle(handlerInput, error) {
    const {
      responseBuilder
    } = handlerInput;

    console.log(`Error handled: ${error.message}`);
    console.log(`Error stack: ${error.stack}`);

    return responseBuilder
      .withShouldEndSession(true)
      .speak('I\'m sorry, something went wrong. Please try again later.')
      .getResponse();
  },
};
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.