Errors

The Python API is designed to raise exceptions for any problems that occur during usage, where the exceptions are grouped by four major categories depending on the cause.

Users are encouraged to handle exceptions as they see fit, but the major groups should at least be considered. They can be accessed as shown in the following snippet.

try:
    dt.Project.list_members('<PROJECT_ID>')
except dt.errors.ServerError as e:
    server_error_handler(e)
except dt.errors.UsageError as e:
    usage_error_handler(e)
except dt.errors.ConnectionError as e:
    connection_error_handler(e)
except dt.errors.UnknownError as e:
    generic_error_handler(e)

ServerError

Covers API responses with a status code in the 500 range.

exception disruptive.errors.InternalServerError(message)

The response contained a status code of 500. https://developer.d21s.com/docs/error-codes#500

UsageError

Covers API responses with a status code in the 400 range in addition to problems caused by invalid parameter inputs.

exception disruptive.errors.BadRequest(message)

The response contained a status code of 400. https://developer.d21s.com/docs/error-codes#400

exception disruptive.errors.Unauthorized(message)

The response contained a status code of 401. https://developer.d21s.com/docs/error-codes#401

exception disruptive.errors.Forbidden(message)

The response contained a status code of 403. https://developer.d21s.com/docs/error-codes#403

exception disruptive.errors.NotFound(message)

The response contained a status code of 404. https://developer.d21s.com/docs/error-codes#404

exception disruptive.errors.Conflict(message)

The response contained a status code of 409. https://developer.d21s.com/docs/error-codes#409

exception disruptive.errors.TooManyRequests(message)

The response contained a status code of 429. https://developer.d21s.com/docs/error-codes#429

exception disruptive.errors.FormatError(message)

Some string formatting, usually a timestamp, is wrong.

exception disruptive.errors.ConfigurationError(message)

One or more configuration parameters are invalid.

ConnectionError

Covers errors caused by unsuccessful connections from the client.

exception disruptive.errors.ConnectionError(message)

Covers errors caused by unsuccessful connections from the client. These are mostly captured requests exceptions.

exception disruptive.errors.ReadTimeout(message)

Could not connection to server in the alloted amount of time set by request_timeout.

BatchError

Unlike the other exceptions, a BatchError is not raised, but returned to the user as a class object with information for them to deal with as they see fit. They are used in batch-style functions like transfer_devices() and batch_update_labels() that may fail one- or several action in an otherwise successful request.

class disruptive.errors.TransferDeviceError(error)

Represents errors that occur when a device can, for some reason, not be transferred from one project to another.

Variables:
  • device_id (str) – Unique ID of the source device.

  • project_id (str) – Unique ID of the source project.

  • status_code (str) – A status code for the returned error. Is either “INVALID_ARGUMENT”, “NOT_FOUND”, or “INTERNAL_ERROR”.

  • message (str) – Described the cause of the error.

class disruptive.errors.LabelUpdateError(error)

Represents errors that occur when a label can, for some reason, not be updated for a device.

Variables:
  • device_id (str) – Unique ID of the source device.

  • project_id (str) – Unique ID of the source project.

  • status_code (str) – A status code for the returned error. Is either “INVALID_ARGUMENT”, “NOT_FOUND”, or “INTERNAL_ERROR”.

  • message (str) – Described the cause of the error.

UnknownError

exception disruptive.errors.UnknownError(message)

An unexpected exception has been raised.

This is likely due to a bug in the package. Please report this to developer-support@disruptive-technologies.com.