1

I want to handle 401, 500 error with custom response. Flask provides a nice way,

@app.errorhandler(401)

Is there any similar way for Chalice? I changed the Gateway Response from API Gateway via console and everytime I deploy my chalice app, I need to change it manually. Is there any automated way of doing that?

1 Answers1

0

Chalice provides a built in set of exception classes that map to common HTTP errors.

See the documentation

Almog-at-Nailo
  • 1,152
  • 1
  • 4
  • 20
  • I am looking for something similar to Middleware or decorator that will handle certain error globally. The solution you suggested is not customizable. Thanks for your valuable suggestion. – A Raihan Bhuiyan Jul 04 '21 at 11:23
  • I see. Well AFAIK there is nothing built into chalice that does that, but I could be wrong – Almog-at-Nailo Jul 04 '21 at 11:46
  • Middleware & Decorator can be solution but I feel like there is a lack in documentation. Seems like I need to dig deeper. Thanks for your suggestion. https://github.com/aws/chalice/pull/1549 https://github.com/aws/chalice/issues/1282 – A Raihan Bhuiyan Jul 04 '21 at 13:30