This repository has been archived by the owner on Aug 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add new exception and little bi format code
- Loading branch information
1 parent
227ae22
commit 7b0e7d2
Showing
5 changed files
with
117 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,71 @@ | ||
""" | ||
System exception | ||
""" | ||
|
||
|
||
class VaildateUIDError(Exception): | ||
""" Raised when the UID is not valid. """ | ||
|
||
class ProfileNotFounded(Exception): | ||
""" Raised when the profile is not found. """ | ||
|
||
class BuildNotPublicData(Exception): | ||
""" Raised when the profile hoyos has public to hidden """ | ||
""" | ||
EnkaNetwork network exception | ||
""" | ||
|
||
class HTTPException(Exception): | ||
""" Exception that's raised when an HTTP request operation fails. """ | ||
|
||
class EnkaValidateFailed(HTTPException): | ||
""" Exception that's raised for when status code 400 occurs.""" | ||
class EnkaNetworError(Exception): | ||
"""Base class for EnkaNetwork errors.""" | ||
|
||
class EnkaPlayerNotFound(Exception): | ||
""" Raised when the UID is not found. """ | ||
|
||
class EnkaServerError(HTTPException): | ||
class NetworkError(EnkaNetworError): | ||
"""Base class for exceptions due to networking errors.""" | ||
|
||
|
||
class TimedOut(NetworkError): | ||
"""Raised when a request took too long to finish.""" | ||
|
||
|
||
class EnkaServerError(EnkaNetworError): | ||
""" Exception that's raised for when status code 500 occurs.""" | ||
|
||
class EnkaServerMaintanance(HTTPException): | ||
|
||
class EnkaServerMaintanance(EnkaNetworError): | ||
""" Exception that's raised when status code 424 occurs. """ | ||
|
||
class EnkaServerRateLimit(HTTPException): | ||
|
||
class EnkaServerRateLimit(EnkaNetworError): | ||
""" Exception that's raised when status code 429 occurs.""" | ||
|
||
class EnkaServerUnknown(HTTPException): | ||
|
||
class EnkaServerUnknown(EnkaNetworError): | ||
""" Exception that's raised when status code 503 occurs. """ | ||
|
||
|
||
""" | ||
EnkaNetwork response error | ||
""" | ||
|
||
|
||
class ProfileNotFounded(Exception): | ||
""" Raised when the profile is not found. """ | ||
|
||
|
||
class BuildNotPublicData(Exception): | ||
""" Raised when the profile hoyos has public to hidden """ | ||
|
||
|
||
class EnkaValidateFailed(EnkaNetworError): | ||
""" Exception that's raised for when status code 400 occurs.""" | ||
|
||
|
||
class EnkaPlayerNotFound(Exception): | ||
""" Raised when the UID is not found. """ | ||
|
||
|
||
ERROR_ENKA = { | ||
400: [VaildateUIDError, "Validate UID {uid} failed."], | ||
404: [EnkaPlayerNotFound, "Player ID {uid} not found. Please check your UID / Username"], | ||
404: [EnkaPlayerNotFound, "Player ID {uid} not found. Please check your UID / Username"], # noqa | ||
429: [EnkaServerRateLimit, "Enka.network has been rate limit this path"], | ||
424: [EnkaServerMaintanance, "Enka.Network doing maintenance server. Please wait took 5-8 hours or 1 day"], | ||
500: [EnkaServerError, "Enka.network server has down or Genshin server broken."], | ||
424: [EnkaServerMaintanance, "Enka.Network doing maintenance server. Please wait took 5-8 hours or 1 day"], # noqa | ||
500: [EnkaServerError, "Enka.network server has down or Genshin server broken."], # noqa | ||
503: [EnkaServerUnknown, "I screwed up massively"] | ||
} | ||
} |
Oops, something went wrong.