Skip to content

Commit

Permalink
Python generic exception handling (#3473)
Browse files Browse the repository at this point in the history
* update python wrapper to handle generic execptions, and return a SeldonMessage

* update branch

* formatting
  • Loading branch information
mwm5945 committed Aug 10, 2021
1 parent bbfa54f commit eb06ffa
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions python/seldon_core/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ def get_rest_microservice(user_model, seldon_metrics):
logger.info("Registering the custom error handler...")
app.register_blueprint(user_model.model_error_handler)

@app.errorhandler(Exception)
def handle_generic_exception(e):
error = SeldonMicroserviceException(
message=str(e), status_code=500, reason="MICROSERVICE_INTERNAL_ERROR"
)
response = jsonify(error.to_dict())
logger.error("%s", error.to_dict())
response.status_code = error.status_code
return response

@app.errorhandler(SeldonMicroserviceException)
def handle_invalid_usage(error):
response = jsonify(error.to_dict())
Expand Down

0 comments on commit eb06ffa

Please sign in to comment.