Make error handler send JSON and 500 response