Made the handler catch exceptions and send an error message.