argsloader.base.exception

BaseParseError

class argsloader.base.exception.BaseParseError[source]
Overview:

Base class of all the parse errors.

ParseError

class argsloader.base.exception.ParseError(message: str, unit, value: argsloader.base.value.PValue, info: Tuple[object, ])[source]
Overview:

Error when parse one piece of data.

__eq__(value, /)

Return self==value.

__hash__()

Return hash(self).

__init__(message: str, unit, value: argsloader.base.value.PValue, info: Tuple[object, ])[source]

Constructor of class argsloader.base.exception.ParseError.

Parameters
  • message – String message.

  • unit – Unit which cause this error.

  • value – Value passed in.

  • info – Extra information.

property info

Property info.

Note

Created by hbutils.model, v0.4.7.

Only reading is permitted with the accessor info.

property message

Property message.

Note

Created by hbutils.model, v0.4.7.

Only reading is permitted with the accessor message.

property unit

Property unit.

Note

Created by hbutils.model, v0.4.7.

Only reading is permitted with the accessor unit.

property value

Property value.

Note

Created by hbutils.model, v0.4.7.

Only reading is permitted with the accessor value.

MultipleParseError

class argsloader.base.exception.MultipleParseError(items: List[Tuple[argsloader.base.value.PValue, argsloader.base.exception.ParseError]])[source]
Overview:

Full result of one parsing process.

Can be seen as collection of argsloader.base.exception.ParseError.

__init__(items: List[Tuple[argsloader.base.value.PValue, argsloader.base.exception.ParseError]])[source]

Constructor of class argsloader.base.exception.MultipleParseError.

Parameters

items – Parse error items.

__repr__()[source]

Return repr(self).

__str__()[source]

Return str(self).

property items

Parse error items.

SkippedParseError

class argsloader.base.exception.SkippedParseError(unit)[source]
Overview:

Error used when parsing process is skipped due to the forwarded error.

__init__(unit)[source]

Constructor of class argsloader.base.exception.SkippedParseError.

Parameters

unit – Unit which should do this parsing process.

wrap_exception_class

argsloader.base.exception.wrap_exception_class(cls: Type[Exception]) → Type[argsloader.base.exception.ParseError][source]

Wrap exception class to inherit argsloader.base.exception.ParseError.

Parameters

cls – Class to be wrapped.

Returns

Wrapped exception class, which should be subclass of both cls and argsloader.base.exception.ParseError.

Examples::
>>> from argsloader.base import wrap_exception_class, ParseError
>>> err = wrap_exception_class(ValueError)
>>> err
<class 'ValueParseError'>
>>> issubclass(err, ParseError)
True
>>> issubclass(err, ValueError)
True

wrap_exception

argsloader.base.exception.wrap_exception(ex: Exception, unit, value)argsloader.base.exception.ParseError[source]

Wrap exception object to new exception object with wrapped class.

Parameters
  • ex – Original exception.

  • unit – Unit which cause this exception.

  • value – Value passed in.

Returns

Wrapped exception object, which should be an instance of type(ex) and argsloader.base.exception.ParseError.

Examples::
>>> from argsloader.base import wrap_exception, ParseError
>>> err = wrap_exception(ValueError('this is message', 2, 3, 4), 'unit', 'value')
>>> err
<ValueParseError 0x7f13877146a8 message: 'this is message', unit: 'unit', value: 'value', info: (2, 3, 4)>
>>> isinstance(err, ParseError)
True
>>> isinstance(err, ValueError)
True
>>> err.message
'this is message'
>>> err.unit
'unit'
>>> err.value
'value'
>>> err.info
(2, 3, 4)