Skip to content

Commit

Permalink
Documentation for mojang.error.exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucino772 committed Mar 25, 2021
1 parent d0b590a commit 6241513
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
8 changes: 8 additions & 0 deletions docs/PyMojang/exceptions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Mojang - Exceptions
===

::: mojang.error.exceptions
handler: python
rendering:
show_root_heading: true
show_source: true
13 changes: 13 additions & 0 deletions mojang/error/exceptions.py
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion mojang/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6241513

Please sign in to comment.