typedargs.exceptions module

A generic key-value based exception class.

Summary

Exceptions:

ArgumentError There is a problem with one of the arguments to the function.
ConversionError An error occurred converted an argument to its specified type.
InternalError An unexpected internal error prevented method completion.
KeyValueException An exception taking key value pairs containing exception information.
NotFoundError A method was invoked by name that does not exist.
TypeSystemError An unspecified internal error occurred in the typedargs type system.
ValidationError The type validators attached to a parameter failed.

Reference

exception typedargs.exceptions.KeyValueException(msg, **kwargs)[source]

Bases: Exception

An exception taking key value pairs containing exception information.

KeyValueExceptions provide a convenient way to include additional information about the source or context of an exception without having to convert it all to a formatted string.

Parameters:
  • msg (string) – A short message about the cause of this exception, not including its type or any placeholders
  • **kwargs – Any named parameters that you would like included with this exception
format(exclude_class=False)[source]

Format this exception as a string including class name.

Parameters:exclude_class (bool) – Whether to exclude the exception class name when formatting this exception
Returns:
a multiline string with the message, class name and
key value parameters passed to create the exception.
Return type:string
format_msg()[source]

Format this exception as a string excluding class name.

Returns:
a multiline string with the message and
key value parameters passed to create the exception.
Return type:string
to_dict()[source]

Convert this exception to a dictionary.

Returns:
A dictionary of information about this exception,
Has a ‘reason’ key, a ‘type’ key and a dictionary of params
Return type:dist
exception typedargs.exceptions.ArgumentError(msg, **kwargs)[source]

Bases: typedargs.exceptions.KeyValueException

There is a problem with one of the arguments to the function.

The method could not be called with the arguments passed. This differs from InternalError in that when ArgumentError is returned, it is known that these arguments can never work for this function.

An example would be passing three arguments to a function requiring 4 arguments.

exception typedargs.exceptions.ValidationError(msg, **kwargs)[source]

Bases: typedargs.exceptions.KeyValueException

The type validators attached to a parameter failed.

API routines can impose validation criteria on` their arguments in addition to requiring simply a certain type of argument. A clasic example is the “path” type which can have validators like “readable” or “exists”. When validation fails, this error is thrown.

exception typedargs.exceptions.ConversionError(msg, **kwargs)[source]

Bases: typedargs.exceptions.KeyValueException

An error occurred converted an argument to its specified type.

All API functions take typed parameters. Each type defines conversion operators for python types that are logically related to it. When no valid conversion exists for the data type passed, this error is thrown.

exception typedargs.exceptions.NotFoundError(msg, **kwargs)[source]

Bases: typedargs.exceptions.KeyValueException

A method was invoked by name that does not exist.

Thrown when an attempt to execute an API method is made and the API method does not exist.

exception typedargs.exceptions.TypeSystemError(msg, **kwargs)[source]

Bases: typedargs.exceptions.KeyValueException

An unspecified internal error occurred in the typedargs type system.

There was an error with the type system. This can be due to improperly specifying an unknown type or because the required type was not properly loaded from an external module before a function that used that type was needed.

exception typedargs.exceptions.InternalError(msg, **kwargs)[source]

Bases: typedargs.exceptions.KeyValueException

An unexpected internal error prevented method completion.

The method could not be completed with the user input passed for an unexpected reason. This does not signify a bug in the API method code. More details should be passed in the arguments.