So I am making an project that call user API from github and after 60 times I will get this error:
And I want if user got that error I want it return a page like this:
How can I do that ?
So I am making an project that call user API from github and after 60 times I will get this error:
And I want if user got that error I want it return a page like this:
How can I do that ?
You could accomplish this by using Try/except handling,since it's the best way to handle request errors(in general) sush as (Timeout/to many requests, etc ..) :
try:
r = requests.get(url, params={'s': thing})
except requests.exceptions.Timeout:
# Maybe set up for a retry, or continue in a retry loop
except requests.exceptions.TooManyRedirects:
# Tell the user their URL was bad and try a different one
# You can add more except statements here as well. (for the page you can render it , to be shown in place of that django default error)
give this doc a shot might find it helpful : https://requests.readthedocs.io/en/latest/user/quickstart/#errors-and-exceptions