pocketutils.core.exceptions

The motivation here is simply that Python lacks some standard exceptions that I consider important. Projects can/should subclass from these in addition to the normal Python ones.

Module Contents

class pocketutils.core.exceptions.ErrorUtils

Utilities for creating and modifying errors.

static args(**names)

Decorator. Add a __init__ that calls the superclass and takes any argument in names. The __init__ will set: (self.name=value if name is passed else None) for all name in names.

Parameters

names – A map from str to Type

exception pocketutils.core.exceptions.XException(*args, **kwargs)

Abstract exception whose subclasses can define extra attributes using ErrorTools.args.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.XWarning(*args, **kwargs)

Abstract user warning whose subclasses can define extra attributes using ErrorTools.args.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.ObsoleteWarning(*args, **kwargs)

The code being called is obsolete and/or may be deprecated in the future.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.DeprecatedWarning(*args, **kwargs)

The code being called is deprecated.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.ImmatureWarning(*args, **kwargs)

The code being called is unstable or immature.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.DangerousRequestWarning(*args, **kwargs)

A warning about an operation that is dangerous but is proceeding regardless.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.StrangeRequestWarning(*args, **kwargs)

A warning about a potential result being wrong because weird arguments were passed.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.IgnoringRequestWarning(*args, **kwargs)

A request or passed argument was ignored.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.ImportFailedWarning(*args, **kwargs)

Could not import a recommended package.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.ConfigWarning(*args, **kwargs)

Did not find a recommended config entry, etc.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.AlgorithmWarning(*args, **kwargs)

A warning about a potential result being wrong.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.DataWarning(*args, **kwargs)

External data is suspicious / might contain an error.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.Error(*args, **kwargs)

Abstract exception that could reasonably be recovered from. Subclass names should end with ‘Error’.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.NaturalExpectedError(*args, **kwargs)

Non-specific exception to short-circuit behavior but meaning ‘all ok’.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.CodeIncompleteError(*args, **kwargs)

The code is not finished!

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.IllegalStateError(*args, **kwargs)

An assertion failed marking invalid state, potentially recoverable. .. seealso:: OpStateError

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.UnsupportedOpError(*args, **kwargs)

Used as a replacement for NotImplementedError, where the method should not be implemented. This also differs from NotImplemented in that is permanent and that it should not (usually) be raised in special methods like __lt__.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.NotConstructableError(*args, **kwargs)

Constructing this object is not supported. It’s probably a singleton, static utils, or has factory methods.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.ImmutableError(*args, **kwargs)

Tried to mutate an immutable object.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.OpStateError(*args, **kwargs)

The operation cannot be performed on an object in this state. .. seealso:: IllegalStateError

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.MultipleMatchesError(*args, **kwargs)

Multiple records match when only 1 was expected. Also applies if 0 or records are permitted. Has argument n containing the number.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.UserError(*args, **kwargs)

An error caused by input from a user of an application.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.BadCommandError(*args, **kwargs)

The user passed an invalid command, such as at the command-line.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.ConfigError(*args, **kwargs)

Error while interpreting a config file from the user.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.MissingConfigKeyError(*args, **kwargs)

Missing a required key.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.RefusingRequestError(*args, **kwargs)

The user requested an operation that is understood but is being refused.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.ResourceError(*args, **kwargs)

A problem finding or loading a resource (file, network connection, hardware, etc.).

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.LockedError(*args, **kwargs)

A resource was found but is locked (ex a hardware component in use).

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.MissingEnvVarError(*args, **kwargs)

Missing a required environment variable.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.HashValidationError(*args, **kwargs)

A checksum did not validate.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.IncompatibleDataError(*args, **kwargs)

An operation cannot be applied to data with this property value.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.MismatchedDataError(*args, **kwargs)

A property of the data is different between multiple elements.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.MissingResourceError(*args, **kwargs)

Could not find a resource (general case).

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.LookupFailedError(*args, **kwargs)

Could not find a resource by name.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.InjectionError(*args, **kwargs)

Could not find a class or method name for dependency injection.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.DbLookupError(*args, **kwargs)

Could not find an entry in an external database.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.RequestError(*args, **kwargs)

A generic error related to arguments.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.RefusingError(*args, **kwargs)

General-case refusal to run an operation, not clearly caused by an application user.

See also

RefusingRequestError

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.AmbiguousRequestError(*args, **kwargs)

Insufficient information was passed to resolve the operation.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.ContradictoryRequestError(*args, **kwargs)

Contradictory information was passed.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.ReservedError(*args, **kwargs)

A key is reserved by the code and cannot be used.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.AlreadyUsedError(*args, **kwargs)

A key was specified twice.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.LengthError(*args, **kwargs)

The length is too large or too small.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.LengthMismatchError(*args, **kwargs)

The objects (2 or more) have different lengths.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.WrongDimensionError(*args, **kwargs)

The object has the wrong number of dimensions (ex matrix instead of vector)

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.EmptyCollectionError(*args, **kwargs)

The object has no elements.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.XTypeError(*args, **kwargs)

A TypeError containing the expected and actual types.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.XValueError(*args, **kwargs)

A ValueError containing the value.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.StringPatternError(*args, **kwargs)

A string did not match a required regular expression.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.OutOfRangeError(*args, **kwargs)

A numerical value is outside a required range.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.ZeroDistanceError(*args, **kwargs)

Two (or more) values are the same by distance.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.NullValueError(*args, **kwargs)

A value of None, NaN, or similar was given.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.NumericConversionError(*args, **kwargs)

Could not convert one numeric type to another.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.InexactRoundError(*args, **kwargs)

A floating-point number could not be cast to an integer.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.XKeyError(*args, **kwargs)

KeyError that contains the failed key.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.ParsingError(*args, **kwargs)

Syntax error when parsing.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.UnrecognizedKeyError(*args, **kwargs)

A configuration entry was set, but the code doesn’t recognize that name.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.AbstractWrappedError(*args, **kwargs)

Abstract exception that could reasonably be recovered from. Subclass names should end with ‘Error’.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.DataIntegrityError(*args, **kwargs)

Data is missing, incomplete, or invalid. More complex than a missing value.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.AlgorithmError(*args, **kwargs)

A wrapper for some less meaningful error.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.ConstructionError(*args, **kwargs)

A wrapper for some less meaningful error.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.HardwareError(*args, **kwargs)

Error related to hardware such as an Arduino.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.DeviceConnectionError(*args, **kwargs)

“Could not connect to the device.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.MissingDeviceError(*args, **kwargs)

“Could not find the needed device.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.BadWriteError(*args, **kwargs)

Could not write to a hardware device (typically to a pin).

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.LoadError(*args, **kwargs)

Failed to load a file.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.SaveError(*args, **kwargs)

Failed to save a file.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.CacheLoadError(*args, **kwargs)

Failed to load a file from a cache.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.CacheSaveError(*args, **kwargs)

Failed to save a file to a cache.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.DownloadError(*args, **kwargs)

Failed to download a file.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.DownloadTimeoutError(*args, **kwargs)

User-supplied files.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.UploadError(*args, **kwargs)

Failed to upload a file.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.PathError(*args, **kwargs)

Error involving a path on the filesystem.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.IllegalPathError(*args, **kwargs)

Not a valid path (e.g. not ok on the filesystem).

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.InvalidFileType(*args, **kwargs)

Not a valid file type.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.FileDoesNotExistError(*args, **kwargs)

A file is expected, but the path does not exist.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.DirDoesNotExistError(*args, **kwargs)

A directory is expected, but the path does not exist.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.PathExistsError(*args, **kwargs)

The path already exists.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.XFileExistsError(*args, **kwargs)

The file already exists.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.PathIsNotAFileError(*args, **kwargs)

The path already exists and is not a file.

Initialize self. See help(type(self)) for accurate signature.

exception pocketutils.core.exceptions.PathIsNotADirError(*args, **kwargs)

The path already exists and is not a directory.

Initialize self. See help(type(self)) for accurate signature.