benchling_sdk.errors module¶

Specialized Exception classes.

exception BenchlingError¶

Bases: Exception

An error resulting from communicating with the Benchling API.

This could be an error returned from the API intentionally (e.g., 400 Bad Request) or an unexpected transport error (e.g., 502 Bad Gateway)

The json attribute is present if the API response provided a deserializable JSON body as part of the error description. It will be None if the response could not be parsed as JSON.

The content attribute is any unparsed content returned as part of the response body.

__init__(status_code: int, headers: MutableMapping[str, str], json: Optional[Dict[str, str]], content: Optional[bytes], parsed: Union[None, ForbiddenError, NotFoundError, BadRequestError, BadRequestErrorBulk, ConflictError]) → None¶
content: Optional[bytes]¶
classmethod from_response(response: benchling_api_client.v2.types.Response) → BenchlingError¶

Create a BenchlingError from a generated Response.

headers: MutableMapping[str, str]¶
json: Optional[Dict[str, str]]¶
parsed: Union[None, ForbiddenError, NotFoundError, BadRequestError, BadRequestErrorBulk, ConflictError]¶
status_code: int¶
exception RegistrationError¶

Bases: Exception

An error relating to Benchling registration.

__init__(message: Optional[str] = None, errors: Optional[Dict[Any, Any]] = None, task_status: Optional[AsyncTaskStatus] = None) → None¶
errors: Optional[Dict[Any, Any]] = None¶
classmethod from_task(task: AsyncTask) → RegistrationError¶

Create a RegistrationError from a failed AsyncTask.

message: Optional[str] = None¶
task_status: Optional[AsyncTaskStatus] = None¶
exception WaitForTaskExpiredError¶

Bases: Exception

An error indicating an AsyncTask did not complete in the time allotted for polling.

__init__(message: str, task: AsyncTask) → None¶
message: str¶
task: AsyncTask¶
raise_for_status(response: benchling_api_client.v2.types.Response) → None¶

Evaluate a Response for a successful HTTP status code or raise a BenchlingError.