User Defined Exceptions
pcapkit.exceptions
refined built-in exceptions.
Make it possible to show only user error stack infomation ,
when exception raised on user’s operation.
-
exception pcapkit.utilities.exceptions.BaseError(*args, quiet=False, **kwargs)[source]
Bases: Exception
Base error class of all kinds.
Important
Turn off system-default traceback function by set sys.tracebacklimit
to 0
.
But bugs appear in Python 3.6, so we have to set sys.tracebacklimit
to None
.
Note
This note is deprecated since Python fixed the problem above.
In Python 2.7, trace.print_stack(limit)()
dose not support negative limit.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.DigitError(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, TypeError
The argument(s) must be (a) number(s).
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.IntError(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, TypeError
The argument(s) must be integral.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.RealError(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, TypeError
The function is not defined for real number.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.ComplexError(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, TypeError
The function is not defined for complex instance.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.BoolError(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, TypeError
The argument(s) must be bool
type.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.BytesError(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, TypeError
The argument(s) must be bytes
type.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.StringError(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, TypeError
The argument(s) must be str
type.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.BytearrayError(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, TypeError
The argument(s) must be bytearray
type.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.DictError(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, TypeError
The argument(s) must be dict
type.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.ListError(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, TypeError
The argument(s) must be list
type.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.TupleError(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, TypeError
The argument(s) must be tuple
type.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.IterableError(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, TypeError
The argument(s) must be iterable.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.IOObjError(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, TypeError
The argument(s) must be file-like object.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.ProtocolUnbound(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, TypeError
Protocol slice unbound.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.CallableError(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, TypeError
The argument(s) must be callable.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.InfoError(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, TypeError
The argument(s) must be Info
instance.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.IPError(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, TypeError
The argument(s) must be IP address.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.EnumError(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, TypeError
The argument(s) must be enumeration protocol type.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.ComparisonError(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, TypeError
Rich comparison not supported between instances.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.RegistryError(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, TypeError
The argument(s) must be registry type.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.FormatError(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, AttributeError
Unknown format(s).
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.UnsupportedCall(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, AttributeError
Unsupported function or property call.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.FileError(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, OSError
[Errno 5] Wrong file format.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.FileExists(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, FileExistsError
[Errno 17] File already exists.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.FileNotFound(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, FileNotFoundError
[Errno 2] File not found.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.ProtocolNotFound(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, IndexError
Protocol not found in ProtoChain.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.VersionError(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, ValueError
Unknown IP version.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.IndexNotFound(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, ValueError
Protocol not in ProtoChain.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.ProtocolError(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, ValueError
Invalid protocol format.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.EndianError(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, ValueError
Invalid endian (byte order).
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.KeyExists(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, ValueError
Key already exists.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.ProtocolNotImplemented(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, NotImplementedError
Protocol not implemented.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.VendorNotImplemented(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, NotImplementedError
Vendor not implemented.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.StructError(*args, eof=False, **kwargs)[source]
Bases: BaseError
, error
Unpack failed.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
eof (bool) –
**kwargs –
- Return type
None
-
exception pcapkit.utilities.exceptions.MissingKeyError(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, KeyError
Key not found.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.FragmentError(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, KeyError
Invalid fragment dict.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.PacketError(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, KeyError
Invalid packet dict.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
exception pcapkit.utilities.exceptions.ModuleNotFound(*args, quiet=False, **kwargs)[source]
Bases: BaseError
, ModuleNotFoundError
Module not found.
- Parameters
*args (Any) – Arbitrary positional arguments.
quiet (bool) – If True
, suppress exception message.
**kwargs (Any) – Arbitrary keyword arguments.
- Return type
None
-
pcapkit.utilities.exceptions.stacklevel()[source]
Fetch current stack level.
The function will walk through the straceback stack (traceback.extract_stack()
),
and fetch the stack level where the path contains /pcapkit/
. So that it won’t
display any disturbing internal traceback information when raising errors.
- Return type
int
- Returns
Stack level until internal stacks, i.e. contains /pcapkit/
.