bcgov / cas-obps

0 stars 0 forks source link

API: Create error handling component #246

Closed pbastia closed 3 months ago

pbastia commented 3 months ago

Description:

@DataVillage what would be the responsibility of this component?

Component is responsible for returning the correct error code when an exception is caught. For example, 404 when a resource is not found, 400 when something invalid is posted etc. Further, it provides meaningful error messages with readable timestamps and clear messages.

Spring Java example at https://www.baeldung.com/global-error-handler-in-a-spring-rest-api.

Acceptance Criteria:

Given Invalid API Request When Hitting API endpoint Then Return appropriate user friendly error message

Development Checklist:

Definition of Ready (Note: If any of these points are not applicable, mark N/A)

·Definition of Done (Note: If any of these points are not applicable, mark N/A)

Notes:

Dependencies

DataVillage commented 3 months ago

Component would be responsible for returning the correct error code when an exception is caught. For example, 404 when a resource is not found, 400 when something invalid is posted etc. Further, it will provide meaningful error messages with readable timestamps and clear messages. So instead of a message just saying "bad request" if you post a string when an integer is expected, it will tell you the parameter that has the issue and that the issue is an invalid format (just one example).

And ideally everything will be performed using a common error handler. Here is a Spring Java example https://www.baeldung.com/global-error-handler-in-a-spring-rest-api. Ideally, something similar can be done with Django.

pbastia commented 3 months ago

I believe @BCerki 's latest PR creates that component. We might be able to close this