Skip to content

Commit

Permalink
Cleanup docstrings, and error messages for exceptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
airblast-dev committed Mar 12, 2024
1 parent d142bb4 commit f6a8940
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion vshieldpy/exceptions/auth_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ class InvalidAuthKey(VShieldpyException):

def __init__(self, auth_key):
super().__init__(
f"Invalid auth key was provided, auth key must be a base16 string. "
f"Invalid auth key was provided, auth key must be a base16 integer as a string. "
f"{auth_key} is not a valid key."
)
5 changes: 1 addition & 4 deletions vshieldpy/exceptions/base_exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@


class VShieldpyException(Exception):
"""Raised if there is an unkown API error returned. Also serves as a base exception.
Can also mean format wise correct but invalid auth key was provided.
"""
"""Raised if there is an unkown API error returned. Also serves as a base exception."""

def __init__(self, error: str | None = None, api_error: str | None = None):
super().__init__(
Expand Down
16 changes: 8 additions & 8 deletions vshieldpy/exceptions/id_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ def __init__(self, server_id: str):
)


class InvalidTaskID(InvalidID):
"""Raised when a provided Service ID is invalid."""
class InvalidServiceID(InvalidID):
"""Raised when a provided service ID is invalid."""

def __init__(self, task_id: str):
def __init__(self, service_id: str):
super().__init__(
f"Invalid Task ID was provided. {task_id} is not an accepted Task ID."
f"Invalid Service ID was provided. {service_id} is not an accepted Service ID."
)


class InvalidServiceID(InvalidID):
"""Raised when a provided Server ID is invalid."""
class InvalidTaskID(InvalidID):
"""Raised when a provided task ID is invalid."""

def __init__(self, service_id: str):
def __init__(self, task_id: str):
super().__init__(
f"Invalid Service ID was provided. {service_id} is not an accepted Service ID."
f"Invalid Task ID was provided. {task_id} is not an accepted Task ID."
)
9 changes: 6 additions & 3 deletions vshieldpy/exceptions/parameter_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@


class InvalidParameter(VShieldpyException):
"""Raised if an invalid parameter was provided for any function or request."""
"""Raised if an invalid parameter was provided for a request.
Means the API did not respond with any information about the reason of the error beyond being a parameter error.
"""

def __init__(self, msg: str | None = None):
super().__init__(
Expand All @@ -35,7 +38,7 @@ class InvalidHostname(InvalidParameter):
def __init__(self, hostname: str):
super().__init__(
"Invalid hostname provided. Hostname can only contain alphabetic ascii characters"
f', and must be at most 16 characters. Provided hostname was "{hostname}".'
f', and must be at most 16 characters long. Provided hostname was "{hostname}".'
)


Expand All @@ -52,7 +55,7 @@ def __init__(self, provided_val: Any, expected_vals: Sequence[int] | str):
)


class InvalidMonths(InvalidDuration, ValueError):
class InvalidMonths(InvalidDuration):
"""Raised if an order, or renewal was attempted with a non-accepted duration in months."""

def __init__(self, provided_val: Any, expected_vals: Sequence[int]):
Expand Down

0 comments on commit f6a8940

Please sign in to comment.