Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internationalisation of error handling #74

Open
jawrainey opened this issue Apr 12, 2021 · 0 comments
Open

Internationalisation of error handling #74

jawrainey opened this issue Apr 12, 2021 · 0 comments
Labels
consumer Consumer API feature new feature or request

Comments

@jawrainey
Copy link
Member

Currently, when we raise a CustomException we manually write a "reason" in the response. This is not ideal as these are in English whereas localisation should occur on the clients of the consumer API (patient and clinical apps). As such, we should ideally return a set of pre-defined keys that clients can use to lookup appropriate messages to send to users, for example, INVALID_TOKEN.

I suggest that we add an enum (named ResponseErrors) to errors.py and modify CustomException so that it holds a list of ResponseErrors.

As an example, the inventory service would change from:

if res.status_code == 429:
        raise CustomException(errors=["Rate Limit on API access."], status_code=429)

to:

if res.status_code == 429:
        raise CustomException(errors=[ResponseErrors.RATE_LIMIT], status_code=429)
@jawrainey jawrainey added consumer Consumer API feature new feature or request labels Apr 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consumer Consumer API feature new feature or request
Projects
None yet
Development

No branches or pull requests

1 participant