Skip to content
Pasqal Documentation

Errors

Here are the different exceptions that the SDK may rise.

BatchCancellingError(e)

Bases: BatchException

Exception class raised when batch cancelling failed.

Source code in pasqal_cloud/errors.py
def __init__(self, e: HTTPError) -> None:
    super().__init__("Batch cancelling failed", e)

BatchClosingError(e)

Bases: BatchException

Exception class raised when closing batch failed.

Source code in pasqal_cloud/errors.py
def __init__(self, e: HTTPError) -> None:
    super().__init__("Unable to close batch.", e)

BatchCreationError(e)

Bases: BatchException

Exception class when batch creation failed

Source code in pasqal_cloud/errors.py
def __init__(self, e: HTTPError) -> None:
    super().__init__("Batch creation failed", e)

BatchException(msg, e=None)

Bases: ExceptionWithResponseContext

Base Exception class for batches

Source code in pasqal_cloud/errors.py
def __init__(self, msg: str, e: Optional[HTTPError] = None):
    if not e:
        return super().__init__(msg)

    if e.response is None:
        return super().__init__(msg)

    resp: Response = e.response

    if not resp.content:
        return super().__init__(msg)
    data = resp.json()

    code = data.get("code", 0)

    if data.get("data", ""):
        description = data["data"].get("description", data.get("message"))
    else:
        description = data.get("message", "")

    return super().__init__(
        f"{msg}: {code}: {description}\nDetails: {json.dumps(data, indent=2)}"
    )

BatchFetchingError(e)

Bases: BatchException

Exception class raised when batch fetching failed.

Source code in pasqal_cloud/errors.py
def __init__(self, e: HTTPError) -> None:
    super().__init__("Batch fetching failed", e)

DeviceSpecsException

Bases: BaseException

Base Exception class for device specs

DeviceSpecsFetchingError(e)

Bases: DeviceSpecsException

Exception class raised when fetching of device specs failed.

Source code in pasqal_cloud/errors.py
def __init__(self, e: HTTPError) -> None:
    super().__init__("Device specs fetching failed", e)

InvalidWorkloadResultsFormatError(result_type)

Bases: WorkloadException

Exception class raised when download results succeeded but format is not as expected.

Source code in pasqal_cloud/errors.py
def __init__(self, result_type: type) -> None:
    super().__init__(f"Workload results should be dict but received {result_type}")

JobCancellingError(e)

Bases: JobException

Exception class raised when job cancelling failed.

Source code in pasqal_cloud/errors.py
def __init__(self, e: HTTPError) -> None:
    super().__init__("Job cancelling failed", e)

JobCreationError(e)

Bases: JobException

Exception class raised when job creation failed.

Source code in pasqal_cloud/errors.py
def __init__(self, e: HTTPError) -> None:
    super().__init__("Job creation failed", e)

JobException(msg, e=None)

Bases: ExceptionWithResponseContext

Base Exception class for jobs.

Source code in pasqal_cloud/errors.py
def __init__(self, msg: str, e: Optional[HTTPError] = None):
    if not e:
        return super().__init__(msg)

    if e.response is None:
        return super().__init__(msg)

    resp: Response = e.response

    if not resp.content:
        return super().__init__(msg)
    data = resp.json()

    code = data.get("code", 0)

    if data.get("data", ""):
        description = data["data"].get("description", data.get("message"))
    else:
        description = data.get("message", "")

    return super().__init__(
        f"{msg}: {code}: {description}\nDetails: {json.dumps(data, indent=2)}"
    )

JobFetchingError(e)

Bases: JobException

Exception class raised when job fetching failed.

Source code in pasqal_cloud/errors.py
def __init__(self, e: HTTPError) -> None:
    super().__init__("Job fetching failed", e)

JobRetryError()

Bases: Exception

Exception class raised when job retry failed.

Source code in pasqal_cloud/errors.py
def __init__(self) -> None:
    super().__init__("Job retry failed.")

OnlyCompleteOrOpenCanBeSet()

Bases: BaseException

Exception class raised when both complete and open arguments are set on a batch.

Source code in pasqal_cloud/errors.py
def __init__(self) -> None:
    super().__init__("Only complete or open can be set when creating a batch.")

RebatchError(e)

Bases: BatchException

Exception class raised when batch retry failed.

Source code in pasqal_cloud/errors.py
def __init__(self, e: HTTPError) -> None:
    super().__init__("Batch retry failed", e)

WorkloadCancellingError(e)

Bases: WorkloadException

Exception class raised when cancelling workload failed.

Source code in pasqal_cloud/errors.py
def __init__(self, e: HTTPError) -> None:
    super().__init__("Workload cancelling failed", e)

WorkloadCreationError(e)

Bases: WorkloadException

Exception class raised when workload creation failed.

Source code in pasqal_cloud/errors.py
def __init__(self, e: HTTPError) -> None:
    super().__init__("Job creation failed", e)

WorkloadException(msg, e=None)

Bases: ExceptionWithResponseContext

Base exception class for workloads.

Source code in pasqal_cloud/errors.py
def __init__(self, msg: str, e: Optional[HTTPError] = None):
    if not e:
        return super().__init__(msg)

    if e.response is None:
        return super().__init__(msg)

    resp: Response = e.response

    if not resp.content:
        return super().__init__(msg)
    data = resp.json()

    code = data.get("code", 0)

    if data.get("data", ""):
        description = data["data"].get("description", data.get("message"))
    else:
        description = data.get("message", "")

    return super().__init__(
        f"{msg}: {code}: {description}\nDetails: {json.dumps(data, indent=2)}"
    )

WorkloadFetchingError(e)

Bases: WorkloadException

Exception class raised when workload fetching failed.

Source code in pasqal_cloud/errors.py
def __init__(self, e: HTTPError) -> None:
    super().__init__("Workload fetching failed", e)

WorkloadResultsConnectionError(e)

Bases: BaseException

Exception class raised when failed to download results for a connection error.

Source code in pasqal_cloud/errors.py
def __init__(self, e: ConnectionError) -> None:
    super().__init__("Workload results download failed from connection error.", e)

WorkloadResultsDecodeError()

Bases: WorkloadException

Exception class raised when download results succeeded but decoding failed.

Source code in pasqal_cloud/errors.py
def __init__(self) -> None:
    super().__init__("Workload results decoding failed.")

WorkloadResultsDownloadError(e)

Bases: WorkloadException

Exception class raised when failed to download results.

Source code in pasqal_cloud/errors.py
def __init__(self, e: HTTPError) -> None:
    super().__init__("Workload results download failed.", e)