Skip to content

Commit

Permalink
Added new base exception
Browse files Browse the repository at this point in the history
  • Loading branch information
danyi1212 committed Oct 14, 2024
1 parent 3f51840 commit 65de845
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions permit/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,22 @@

import aiohttp
from loguru import logger
from typing_extensions import deprecated

from permit import ErrorDetails, HTTPValidationError

DEFAULT_SUPPORT_LINK = "https://permit-io.slack.com/ssb/redirect"


class PermitException(Exception): # noqa: N818
class PermitError(Exception):
"""Permit base exception"""


@deprecated("Use PermitError instead")
class PermitException(PermitError): # noqa: N818
"""Permit base exception (deprecated, use PermitError instead)"""


class PermitConnectionError(PermitException):
"""Permit connection exception"""

Expand All @@ -21,7 +27,7 @@ def __init__(self, message: str, *, error: Optional[aiohttp.ClientError] = None)
self.original_error = error


class PermitContextError(Exception):
class PermitContextError(PermitError):
"""
The `PermitContextError` class represents an error that occurs when an API method
is called with insufficient context (not knowing in what environment, project or
Expand All @@ -32,15 +38,15 @@ class PermitContextError(Exception):
"""


class PermitContextChangeError(Exception):
class PermitContextChangeError(PermitError):
"""
The `PermitContextChangeError` will be thrown when the user is trying to set the
SDK context to an object that the current API Key cannot access (and if allowed,
such api calls will result is 401). Instead, the SDK throws this exception.
"""


class PermitApiError(Exception):
class PermitApiError(PermitError):
"""
Wraps an error HTTP Response that occurred during a Permit REST API request.
"""
Expand Down

0 comments on commit 65de845

Please sign in to comment.