Handle error code 422 and 500 in sinatra error handler