diff --git a/docs/PyMojang/exceptions.md b/docs/PyMojang/exceptions.md new file mode 100644 index 00000000..00095ed5 --- /dev/null +++ b/docs/PyMojang/exceptions.md @@ -0,0 +1,8 @@ +Mojang - Exceptions +=== + +::: mojang.error.exceptions + handler: python + rendering: + show_root_heading: true + show_source: true \ No newline at end of file diff --git a/mojang/error/exceptions.py b/mojang/error/exceptions.py index 83bf5061..a2f34c95 100644 --- a/mojang/error/exceptions.py +++ b/mojang/error/exceptions.py @@ -1,41 +1,54 @@ # Global class MethodNotAllowed(Exception): + """The method used for the request is not allowed in the requested url""" code = 405 class NotFound(Exception): + """The requested url doesn't exists""" code = 404 class ServerError(Exception): + """There is an internal error on the requested server""" code = 500 class PayloadError(Exception): + """The data that has been sent to the server is not formated correctly""" code = 400 # Authentication Errors class CredentialsError(Exception): + """The credentials sent to the server are wrong""" code = [403, 429] class TokenError(Exception): + """The token sent to the server is invalid""" code = 403 class Unauthorized(Exception): + """The token sent to the server is invalid""" code = 401 # Name Change Errors class InvalidName(Exception): + """The name is invalid, longer than 16 characters or contains characters other than (a-zA-Z0-9_). + Only raised when changing the name of a user + """ code = 400 def __init__(self): super().__init__("Name is invalid, longer than 16 characters or contains characters other than (a-zA-Z0-9_)") class UnavailableName(Exception): + """Name is unavailable. Only raised when changing the name of a user""" code = 403 def __init__(self): super().__init__("Name is unavailable") # Security class IPNotSecured(Exception): + """The current IP is not secured. Only raised when checking if user IP is secure""" code = 403 class IPVerificationError(Exception): + """Verifiction for IP failed. Only raised when verifying user IP""" code = 403 diff --git a/mojang/profile.py b/mojang/profile.py index 4385c84e..59ed45b2 100644 --- a/mojang/profile.py +++ b/mojang/profile.py @@ -21,7 +21,7 @@ def create(cls, **kwargs) -> 'UserProfile': """Create a new UserProfile from a dict Args: - **kwargs (dict): The dict containing you want to create the profile from + **kwargs (dict): The dict you want to create the profile from Returns: A UserProfile with the attributes from the `kwargs` dict