Thursday, May 2, 2019

How to gracefully fail if API endpoint is not available

Hi,

New programmer so expect me to make mistakes.

I am running Django 2.2 in this app https://github.com/lhaig/usery

This application uses an API endpoint to function.

The home view connects to the API and prepares the data for interaction.

https://github.com/lhaig/usery/blob/master/portal/views.py

Using this module for authentication.

https://github.com/lhaig/usery/blob/master/modules/osauth.py

The problem I currently have is that if the API endpoint is not
available then the site crashes.

How do I check if the API is available and then display and error for
example "API endpoint unavailable check config or the API"

I was thinking of using a try catch scenario but I have had no luck.

Does anyone have a suggestion as to how I could do this?

Regards

Lance


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/51ac428f-6c81-7b55-efda-eb407206d59c%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment