Community Support

ErrorHandler in the Swift Tutorial

Hi there. I’ve been following along in the Swift tutorial to try to move my Alexa cooking skill over to mobile. So far pretty good, but I might have found an issue.

I’m using the Amazon Node.js SDK for my skill. In my code the “ErrorHandler” isn’t one the request handlers registered with the SkillBuilder. It’s added separately with “.addErrorHandlers”. The tutorial doesn’t do it that way. Just checking to see if that is an oversight.

Hi FoodNerd -

Yes, that part is just a little different. With Spokestack an NLU error actually gets handled in a different part of the code. Either in the NLUDelegate.failure or completion.failure depending how it’s set up. See this page in the docs for more details.

Generally the classifier will always return an intent of some kind, so under normal use you shouldn’t expect the failures to happen much at all. What’s more likely is you get an intent that is not handled by your code. That’s where the ErrorHandler comes in. It always returns true for its canHandle function. So despite its name, it ends up being a fallback handler rather than an error handler. I just left it as ErrorHandler for consistency with the node.js code.

Regards,
Daniel