Skip to content

Commit f2e2b4a

Browse files
authored
Handle response code 500 (#3)
1 parent 3f766f1 commit f2e2b4a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

pons/client.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import requests
44

5-
from .errors import DictionaryNotFound, LimitReached, Unauthorized
5+
from .errors import DictionaryNotFound, LimitReached, Unauthorized, InternalServerError
66
from .models import Dictionary, Hit, Language, create_hit
77

88
__all__ = ("Client",)
@@ -30,6 +30,8 @@ def request(
3030
raise Unauthorized()
3131
if status == 404:
3232
raise DictionaryNotFound()
33+
if status == 500:
34+
raise InternalServerError()
3335
if status == 503:
3436
raise LimitReached()
3537
return res.json()

pons/errors.py

+4
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ class LimitReached(PONSException):
1515

1616
class Unauthorized(PONSException):
1717
"""The supplied credentials could not be verified or the access to a dictionary is not allowed."""
18+
19+
20+
class InternalServerError(PONSException):
21+
"""An internal server error has occurred."""

0 commit comments

Comments
 (0)