Fix error handler for exceptions that do not have a message

The error handler assumes data will always have a "message" key, which might not always be true.