benchling_sdk.errors module¶
Specialized Exception classes.
- exception AppSessionClosedError¶
Bases:
benchling_sdk.errors.ExtendedBenchlingErrorBase
An error indicating a Benchling App session was already closed when attempting an API update.
- classmethod error_matcher() ResponseErrorMatcher[AppSessionClosedError] ¶
Create an instance of ResponseErrorMatcher matching AppSessionClosedError.
- 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.
Instead of extending this class directly, prefer extending ExtendedBenchlingErrorBase.
- __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 ¶
- classmethod from_response(response: benchling_api_client.v2.types.Response) BenchlingError ¶
Create a BenchlingError from a generated Response.
- parsed: Union[None, ForbiddenError, NotFoundError, BadRequestError, BadRequestErrorBulk, ConflictError]¶
- exception DatasetInProgressError¶
Bases:
Exception
An error for Benchling datasets for unavailable data operations on a Dataset in progress.
- exception ExtendedBenchlingErrorBase¶
Bases:
abc.ABC
,benchling_sdk.errors.BenchlingError
Extended Benchling Error.
Prefer using this class instead of extending BenchlingError directly.
Forces subclasses to implement useful helpers.
- abstract classmethod error_matcher() ResponseErrorMatcher[benchling_sdk.errors.ExtendedError] ¶
Create an instance of ResponseErrorMatcher matching an exception extending BenchlingError.
- parsed: Union[None, ForbiddenError, NotFoundError, BadRequestError, BadRequestErrorBulk, ConflictError]¶
- 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.
- task_status: Optional[AsyncTaskStatus] = None¶
- class ResponseErrorMatcher¶
Bases:
Generic
[benchling_sdk.errors.E
]Response Error Matcher.
Raise a more specific Benchling Error if the HTTP response matches specific conditions.
- __init__(error_type: Type[benchling_sdk.errors.E], matcher: ResponseMatcher)¶
Init Response Error Matcher.
- class ResponseMatcher¶
Bases:
Protocol
Callable for checking if a Response matches specified conditions.
- __init__(*args, **kwargs)¶
- exception WaitForTaskExpiredError¶
Bases:
Exception
An error indicating an AsyncTask did not complete in the time allotted for polling.
- raise_for_status(response: benchling_api_client.v2.types.Response, error_matchers: Optional[Iterable[ResponseErrorMatcher[benchling_sdk.errors.E]]] = None) None ¶
Evaluate a Response for a successful HTTP status code or raise a BenchlingError.
Custom error_matchers may be passed to raise more specific types of BenchlingError in a few specialized cases.
If multiple matchers are specified, itâs recommended that the caller provide an ordered Iterable such as List, with the more specific matchers first in the collection. Specifying a broader exception earlier in the collection, with a more narrow exception later, may cause the broader exception to be returned first.