rbtools.api.errors¶
Error classes and codes for API communication.
Functions
|
Create an error instance. |
Exceptions
|
An error communicating with the API. |
|
Authorization error when communicating with the API. |
|
Bad request data made to an API. |
An exception for caching errors. |
|
|
A non-API error when communicating with a server. |
|
An error communicating over SSL or verifying an SSL certificate. |
- exception rbtools.api.errors.APIError(http_status: Optional[int] = None, error_code: Optional[int] = None, rsp: Optional[Dict] = None, message: Optional[str] = None, *args, **kwargs)[source]¶
Bases:
ExceptionAn error communicating with the API.
- default_message: str = 'An error occurred when communicating with Review Board.'¶
The default error message used if a specific error is not available.
New in version 3.1.
- Type:
- __init__(http_status: Optional[int] = None, error_code: Optional[int] = None, rsp: Optional[Dict] = None, message: Optional[str] = None, *args, **kwargs) None[source]¶
Initialize the error.
- Parameters:
http_status (
int, optional) –The HTTP status code associated with this error.
Changed in version 3.1: This is now optional.
error_code (
int, optional) –The API error code associated with this error.
Changed in version 3.1: This is now optional.
rsp (
dict, optional) – The API response payload. This may beNonefor non-API Error payloads.message (
str, optional) –A specific error message to use. This will take precedence over any errors in
rsp.New in version 3.1.
*args (
tuple) – Extra positional arguments to pass to the base constructor.**kwargs (
dict) – Extra keyword arguments to pass to the base constructor.
- __str__() str[source]¶
Return a string representation of the error.
The explicit
messagepassed to the constructor will be used if provided. If not provided, this will fall back to the message in thersppayload, or todefault_message.If an API error code is available, it will be included in the message. If one is not provided, but an HTTP status is available, then it will be included instead.
- Returns:
The error message.
- Return type:
- exception rbtools.api.errors.AuthorizationError(http_status: Optional[int] = None, error_code: Optional[int] = None, rsp: Optional[Dict] = None, message: Optional[str] = None, *args, **kwargs)[source]¶
Bases:
APIErrorAuthorization error when communicating with the API.
- exception rbtools.api.errors.BadRequestError(http_status: Optional[int] = None, error_code: Optional[int] = None, rsp: Optional[Dict] = None, message: Optional[str] = None, *args, **kwargs)[source]¶
Bases:
APIErrorBad request data made to an API.
- exception rbtools.api.errors.ServerInterfaceError(msg: str, *args, **kwargs)[source]¶
Bases:
ExceptionA non-API error when communicating with a server.
- exception rbtools.api.errors.ServerInterfaceSSLError(*, host: str, port: int, ssl_error: SSLError, ssl_context: SSLContext)[source]¶
Bases:
ServerInterfaceErrorAn error communicating over SSL or verifying an SSL certificate.
This class wraps a
ssl.SSLErroror subclass, and attempts to generate a helpful error message with instructions for resolving most common SSL-related issues.New in version 4.1.
- __init__(*, host: str, port: int, ssl_error: SSLError, ssl_context: SSLContext) None[source]¶
Initialize the error.
- Parameters:
host (
str) – The hostname RBTools attempted to connect to.port (
int) – The port RBTools attempted to connect to.ssl_error (
ssl.SSLError) – The original SSL error.ssl_context (
ssl.SSLContext) – The original SSL context.
- ssl_context: SSLContext¶