Module ogr.exceptions
Expand source code
# Copyright Contributors to the Packit project.
# SPDX-License-Identifier: MIT
from typing import Any, Optional
import github
import gitlab
class OgrException(Exception):
"""Something went wrong during our execution."""
class APIException(OgrException):
"""Generic API exception."""
@property
def response_code(self):
raise NotImplementedError()
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
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
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
class OperationNotSupported(OgrException):
"""Raise when the operation is not supported by the backend."""
class IssueTrackerDisabled(OperationNotSupported):
"""Issue tracker on the project is not enabled."""
class OgrNetworkError(OgrException):
"""Exception raised when an unexpected network error occurs."""
class GitForgeInternalError(OgrNetworkError):
"""Exception raised when git forge returns internal failure."""
class GithubAppNotInstalledError(OgrException):
"""Exception raised when GitHub App is not installed."""
Classes
class APIException (*args, **kwargs)
-
Generic API exception.
Expand source code
class APIException(OgrException): """Generic API exception.""" @property def response_code(self): raise NotImplementedError()
Ancestors
- OgrException
- builtins.Exception
- builtins.BaseException
Subclasses
Instance variables
var response_code
-
Expand source code
@property def response_code(self): raise NotImplementedError()
class GitForgeInternalError (*args, **kwargs)
-
Exception raised when git forge returns internal failure.
Expand source code
class GitForgeInternalError(OgrNetworkError): """Exception raised when git forge returns internal failure."""
Ancestors
- OgrNetworkError
- OgrException
- builtins.Exception
- builtins.BaseException
class GithubAPIException (*args, **kwargs)
-
Exception related to Github API.
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
Ancestors
- APIException
- OgrException
- builtins.Exception
- builtins.BaseException
Instance variables
var 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)
-
Exception raised when GitHub App is not installed.
Expand source code
class GithubAppNotInstalledError(OgrException): """Exception raised when GitHub App is not installed."""
Ancestors
- OgrException
- builtins.Exception
- builtins.BaseException
class GitlabAPIException (*args, **kwargs)
-
Exception related to Gitlab API.
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
Ancestors
- APIException
- OgrException
- builtins.Exception
- builtins.BaseException
Instance variables
var 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)
-
Issue tracker on the project is not enabled.
Expand source code
class IssueTrackerDisabled(OperationNotSupported): """Issue tracker on the project is not enabled."""
Ancestors
- OperationNotSupported
- OgrException
- builtins.Exception
- builtins.BaseException
class OgrException (*args, **kwargs)
-
Something went wrong during our execution.
Expand source code
class OgrException(Exception): """Something went wrong during our execution."""
Ancestors
- builtins.Exception
- builtins.BaseException
Subclasses
class OgrNetworkError (*args, **kwargs)
-
Exception raised when an unexpected network error occurs.
Expand source code
class OgrNetworkError(OgrException): """Exception raised when an unexpected network error occurs."""
Ancestors
- OgrException
- builtins.Exception
- builtins.BaseException
Subclasses
class OperationNotSupported (*args, **kwargs)
-
Raise when the operation is not supported by the backend.
Expand source code
class OperationNotSupported(OgrException): """Raise when the operation is not supported by the backend."""
Ancestors
- OgrException
- builtins.Exception
- builtins.BaseException
Subclasses
class PagureAPIException (*args: Any, pagure_error: Optional[str] = None, pagure_response: Optional[dict[str, typing.Any]] = None, response_code: Optional[int] = None)
-
Exception related to Pagure API.
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
Ancestors
- APIException
- OgrException
- builtins.Exception
- builtins.BaseException
Instance variables
var pagure_error
-
Expand source code
@property def pagure_error(self): return self._pagure_error or self.__cause__
var response_code
-
Expand source code
@property def response_code(self): return self._response_code