Module ogr.exceptions

Classes

class APIException (*args, **kwargs)
Expand source code
class APIException(OgrException):
    """Generic API exception."""

    @property
    def response_code(self):
        raise NotImplementedError()

Generic API exception.

Ancestors

Subclasses

Instance variables

prop response_code
Expand source code
@property
def response_code(self):
    raise NotImplementedError()
class ForgejoAPIException (*args, **kwargs)
Expand source code
class ForgejoAPIException(APIException):
    """Exception related to Forgejo API."""

    @staticmethod
    def describe(ex: pyforgejo.core.api_error.ApiError) -> str:
        """
        Short description of a pyforgejo error: the HTTP status and the
        message Forgejo sent. Unlike `str(ex)` it leaves out the response
        headers.
        """
        message = ForgejoAPIException._message_of(ex.body)
        if message is None:
            message = "" if ex.body is None else str(ex.body)
        return f"{ex.status_code} {message}".strip()

    @staticmethod
    def _message_of(body: Any) -> Optional[str]:
        if isinstance(body, dict) and isinstance(body.get("message"), str):
            return body["message"]
        if isinstance(body, str) and body:
            return body
        return None

    @property
    def response_code(self):
        if self.__cause__ is None or not isinstance(
            self.__cause__,
            pyforgejo.core.api_error.ApiError,
        ):
            return None
        return self.__cause__.status_code

    @property
    def forgejo_message(self) -> Optional[str]:
        """Error message from Forgejo's response, if there is one."""
        if self.__cause__ is None or not isinstance(
            self.__cause__,
            pyforgejo.core.api_error.ApiError,
        ):
            return None
        return self._message_of(self.__cause__.body)

Exception related to Forgejo API.

Ancestors

Static methods

def describe(ex: pyforgejo.core.api_error.ApiError) ‑> str
Expand source code
@staticmethod
def describe(ex: pyforgejo.core.api_error.ApiError) -> str:
    """
    Short description of a pyforgejo error: the HTTP status and the
    message Forgejo sent. Unlike `str(ex)` it leaves out the response
    headers.
    """
    message = ForgejoAPIException._message_of(ex.body)
    if message is None:
        message = "" if ex.body is None else str(ex.body)
    return f"{ex.status_code} {message}".strip()

Short description of a pyforgejo error: the HTTP status and the message Forgejo sent. Unlike str(ex) it leaves out the response headers.

Instance variables

prop forgejo_message : str | None
Expand source code
@property
def forgejo_message(self) -> Optional[str]:
    """Error message from Forgejo's response, if there is one."""
    if self.__cause__ is None or not isinstance(
        self.__cause__,
        pyforgejo.core.api_error.ApiError,
    ):
        return None
    return self._message_of(self.__cause__.body)

Error message from Forgejo's response, if there is one.

prop response_code
Expand source code
@property
def response_code(self):
    if self.__cause__ is None or not isinstance(
        self.__cause__,
        pyforgejo.core.api_error.ApiError,
    ):
        return None
    return self.__cause__.status_code
class GitForgeInternalError (*args, **kwargs)
Expand source code
class GitForgeInternalError(OgrNetworkError):
    """Exception raised when git forge returns internal failure."""

Exception raised when git forge returns internal failure.

Ancestors

class GithubAPIException (*args, **kwargs)
Expand source code
class GithubAPIException(APIException):
    """Exception related to Github API."""

    @property
    def response_code(self):
        if self.__cause__ is None or not isinstance(
            self.__cause__,
            github.GithubException,
        ):
            return None
        return self.__cause__.status

Exception related to Github API.

Ancestors

Instance variables

prop response_code
Expand source code
@property
def response_code(self):
    if self.__cause__ is None or not isinstance(
        self.__cause__,
        github.GithubException,
    ):
        return None
    return self.__cause__.status
class GithubAppNotInstalledError (*args, **kwargs)
Expand source code
class GithubAppNotInstalledError(OgrException):
    """Exception raised when GitHub App is not installed."""

Exception raised when GitHub App is not installed.

Ancestors

class GitlabAPIException (*args, **kwargs)
Expand source code
class GitlabAPIException(APIException):
    """Exception related to Gitlab API."""

    @property
    def response_code(self):
        if self.__cause__ is None or not isinstance(self.__cause__, gitlab.GitlabError):
            return None
        return self.__cause__.response_code

Exception related to Gitlab API.

Ancestors

Instance variables

prop response_code
Expand source code
@property
def response_code(self):
    if self.__cause__ is None or not isinstance(self.__cause__, gitlab.GitlabError):
        return None
    return self.__cause__.response_code
class IssueTrackerDisabled (*args, **kwargs)
Expand source code
class IssueTrackerDisabled(OperationNotSupported):
    """Issue tracker on the project is not enabled."""

Issue tracker on the project is not enabled.

Ancestors

class OgrException (*args, **kwargs)
Expand source code
class OgrException(Exception):
    """Something went wrong during our execution."""

Something went wrong during our execution.

Ancestors

  • builtins.Exception
  • builtins.BaseException

Subclasses

class OgrNetworkError (*args, **kwargs)
Expand source code
class OgrNetworkError(OgrException):
    """Exception raised when an unexpected network error occurs."""

Exception raised when an unexpected network error occurs.

Ancestors

Subclasses

class OperationNotSupported (*args, **kwargs)
Expand source code
class OperationNotSupported(OgrException):
    """Raise when the operation is not supported by the backend."""

Raise when the operation is not supported by the backend.

Ancestors

Subclasses

class PagureAPIException (*args: Any,
pagure_error: str | None = None,
pagure_response: dict[str, typing.Any] | None = None,
response_code: int | None = None)
Expand source code
class PagureAPIException(APIException):
    """Exception related to Pagure API."""

    def __init__(
        self,
        *args: Any,
        pagure_error: Optional[str] = None,
        pagure_response: Optional[dict[str, Any]] = None,
        response_code: Optional[int] = None,
    ) -> None:
        super().__init__(*args)
        self._pagure_error = pagure_error
        self.pagure_response = pagure_response
        self._response_code = response_code

    @property
    def pagure_error(self):
        return self._pagure_error or self.__cause__

    @property
    def response_code(self):
        return self._response_code

Exception related to Pagure API.

Ancestors

Instance variables

prop pagure_error
Expand source code
@property
def pagure_error(self):
    return self._pagure_error or self.__cause__
prop response_code
Expand source code
@property
def response_code(self):
    return self._response_code