5. dxpy.exceptions Module

Exceptions for the dxpy package.

exception dxpy.exceptions.DXError[source]

Bases: Exception

Base class for exceptions in this package.

exception dxpy.exceptions.DXAPIError(content, code, timestamp='', req_id='')[source]

Bases: DXError

Exception for when the API server responds with a code that is not 200 (OK). See https://documentation.dnanexus.com/developer/api/protocols#errors for complete documentation of API errors, including those reflected by subclasses of this class.

error_message()[source]

Returns a one-line description of the error.

exception dxpy.exceptions.MalformedJSON(content, code, timestamp='', req_id='')[source]

Bases: DXAPIError

Raised when the input could not be parsed as JSON.

exception dxpy.exceptions.InvalidAuthentication(content, code, timestamp='', req_id='')[source]

Bases: DXAPIError

Raised when the provided OAuth2 token is invalid.

exception dxpy.exceptions.PermissionDenied(content, code, timestamp='', req_id='')[source]

Bases: DXAPIError

Raised when the supplied credentials have insufficient permissions to perform this action.

exception dxpy.exceptions.SpendingLimitExceeded(content, code, timestamp='', req_id='')[source]

Bases: DXAPIError

Raised when the spending limit has been reached for the account that would be billed for this action.

exception dxpy.exceptions.ResourceNotFound(content, code, timestamp='', req_id='')[source]

Bases: DXAPIError

Raised when a specified entity or resource could not be found.

exception dxpy.exceptions.InvalidInput(content, code, timestamp='', req_id='')[source]

Bases: DXAPIError

Raised when the input is syntactically correct (JSON), but semantically incorrect (for example, a JSON array is provided where a hash was required; or a required parameter was missing, etc.).

exception dxpy.exceptions.InvalidState(content, code, timestamp='', req_id='')[source]

Bases: DXAPIError

Raised when the operation is not allowed at this object state.

exception dxpy.exceptions.InvalidType(content, code, timestamp='', req_id='')[source]

Bases: DXAPIError

Raised when an object specified in the request is of invalid type.

exception dxpy.exceptions.RateLimitConditional(content, code, timestamp='', req_id='')[source]

Bases: DXAPIError

Raised when the rate of invalid requests is too high.

exception dxpy.exceptions.InternalError(content, code, timestamp='', req_id='')[source]

Bases: DXAPIError

Raised when the server encountered an internal error.

exception dxpy.exceptions.ServiceUnavailable(content, code, timestamp='', req_id='')[source]

Bases: DXAPIError

Raised when an API service was temporarily unavailable.

exception dxpy.exceptions.DXFileError[source]

Bases: DXError

Exception for dxpy.bindings.dxfile.DXFile.

exception dxpy.exceptions.DXIncompleteReadsError[source]

Bases: DXError

Exception for dxpy.bindings.dxfile.DXFile when returned read data is shorter than requested

exception dxpy.exceptions.DXPartLengthMismatchError[source]

Bases: DXFileError

Exception raised by dxpy.bindings.dxfile.DXFile on part length mismatch.

exception dxpy.exceptions.DXChecksumMismatchError[source]

Bases: DXFileError

Exception raised by dxpy.bindings.dxfile.DXFile on checksum mismatch.

exception dxpy.exceptions.DXSearchError[source]

Bases: DXError

Exception for dxpy.bindings.search methods.

exception dxpy.exceptions.DXAppletError[source]

Bases: DXError

Exception for dxpy.bindings.dxapplet.DXApplet.

exception dxpy.exceptions.DXJobFailureError[source]

Bases: DXError

Exception produced by dxpy.bindings.dxjob.DXJob when a job fails.

exception dxpy.exceptions.ProgramError[source]

Bases: DXError

Deprecated. Use AppError instead.

exception dxpy.exceptions.AppError[source]

Bases: ProgramError

Base class for fatal exceptions to be raised while using dxpy inside DNAnexus execution containers.

This exception is thrown for user errors, and the error message is presented to the user. Throwing this exception will cause the Python execution template to write exception information into the file job_error.json in the current working directory, allowing reporting of the error state through the DNAnexus API.

exception dxpy.exceptions.AppInternalError[source]

Bases: DXError

Base class for fatal exceptions to be raised while using dxpy inside DNAnexus execution containers.

This exception is intended for internal App errors, whose message goes to the App developer. Throwing this exception will cause the Python execution template to write exception information into the file job_error.json in the current working directory, allowing reporting of the error state through the DNAnexus API.

exception dxpy.exceptions.DXCLIError[source]

Bases: DXError

Exception class for generic errors in the command-line client

exception dxpy.exceptions.ContentLengthError[source]

Bases: HTTPError

Raised when actual content length received from the server does not match the “Content-Length” header

exception dxpy.exceptions.HTTPErrorWithContent(value, content)[source]

Bases: HTTPError

Specific variant of HTTPError with response content.

This class was created to avoid appending content directly to error message which makes difficult to format log strings.

exception dxpy.exceptions.BadJSONInReply[source]

Bases: ValueError

Raised when the server returned invalid JSON in the response body. Possible reasons for this are the network connection breaking, or overload on the server.

exception dxpy.exceptions.InvalidTLSProtocol[source]

Bases: DXAPIError

Raised when the connection to the server was reset due to an ssl protocol not supported. Only connections with TLS v1.2 will be accepted.

error_message()[source]

Returns a one-line description of the error.

exception dxpy.exceptions.UrllibInternalError[source]

Bases: AttributeError

Exception class for AttributeError from urllib3

dxpy.exceptions.format_exception(e)[source]

Returns a string containing the type and text of the exception.

dxpy.exceptions.exit_with_exc_info(code=1, message='', print_tb=False, exception=None)[source]

Exits the program, printing information about the last exception (if any) and an optional error message. Uses exception instead if provided.

Parameters:
  • code (integer (valid exit code, 0-255)) – Exit code.

  • message (string) – Message to be printed after the exception information.

  • print_tb (boolean) – If set to True, prints the exception traceback; otherwise, suppresses it.

dxpy.exceptions.err_exit(message='', code=None, expected_exceptions=(<class 'urllib3.exceptions.ProtocolError'>, <class 'urllib3.exceptions.NewConnectionError'>, <class 'urllib3.exceptions.DecodeError'>, <class 'urllib3.exceptions.ConnectTimeoutError'>, <class 'urllib3.exceptions.ReadTimeoutError'>, <class 'http.client.HTTPException'>, <class 'urllib3.exceptions.SSLError'>, <class 'ssl.SSLError'>, <class 'urllib3.exceptions.HTTPError'>, <class 'OSError'>, <class 'ConnectionResetError'>, <class 'json.decoder.JSONDecodeError'>, <class 'dxpy.exceptions.DXAPIError'>, <class 'dxpy.exceptions.DXCLIError'>, <class 'KeyboardInterrupt'>), arg_parser=None, ignore_sigpipe=True, exception=None)[source]

Exits the program, printing information about the last exception (if any) and an optional error message. Uses exception instead if provided.

Uses expected_exceptions to set the error code decide whether to suppress the error traceback.

Parameters:
  • message (string) – Message to be printed after the exception information.

  • code (integer (valid exit code, 0-255)) – Exit code.

  • expected_exceptions (iterable) – Exceptions for which to exit with error code 3 (expected error condition) and suppress the stack trace (unless the _DX_DEBUG environment variable is set).

  • arg_parser – argparse.ArgumentParser object used in the program (optional)

  • ignore_sigpipe (boolean) – Whether to exit silently with code 3 when IOError with code EPIPE is raised. Default true.

  • exception – an exception to use in place of the last exception raised