Custom Exception Handler
Batman learned how to create custom error handlers for different exception types in his application. He wrote the following code to handle exceptions and return a custom error response:
py
# GET /hello_world
@app.exception
def handle_exception(error):
return Response(status_code=500, description=f"error msg: {error}", headers={})
py
# GET /hello_world
@app.exception
def handle_exception(error: Exception):
return Response(status_code=500, description=f"error msg: {error}", headers={})
What's next?
Now, Batman wanted to scale his application across multiple cores. Robyn led him to Scaling.