Add error handler that converts message to JSON response.