Exceptions

Module containing all the exceptions used in Pheres

All exception are subclasses of PheresError, except for PheresInternalError. This is intended, as PheresInternalError is only raised in case of bugs and should not be catched. Please make a bug report if you ever encounter PheresInternalError

exception pheres._exceptions.PheresInternalError

Bases: BaseException

Raised when pheres encounters an internal error

If you see this exception, please make a bug report

Variables

msg – explanation of the error

exception pheres._exceptions.PheresError

Bases: Exception

Base exception in pheres for all other exceptions

exception pheres._exceptions.TypeHintError(type: TypeHint, msg: str = '{type} is not a valid JSON type hint')

Bases: pheres._exceptions.PheresError, TypeError

Raised for invalid JSON type hints

Variables
  • type (TypeHint) – invalid type hint

  • msg (str) – explanation of the error

exception pheres._exceptions.JSONTypeError(type: TypeHint, value: Any, msg: str = "{value} doesn't have type {type}")

Bases: pheres._exceptions.PheresError, TypeError

Raised when a value doesn’t have the excepted type

Variables
  • type (TypeHint) – expected type

  • value (Any) – invalid value

  • msg (str) – explanation of the error

exception pheres._exceptions.JSONValueError(value: Any, msg: str = 'invalid JSON {value}')

Bases: pheres._exceptions.PheresError, ValueError

Raised when an invalid json value is encountered

Variables
  • value (Any) – invalid value

  • msg (str) – explanation of the error

exception pheres._exceptions.CycleError(obj: Any, cycle: tuple[Any], msg: str = '{obj} contains the cycle {cycle}')

Bases: pheres._exceptions.PheresError, graphlib.CycleError

Raised when a value has cycles in it

Variables
  • obj (Any) – object containing the cycle

  • cycle (tuple) – detected cycle

  • msg (str) – explanation of the error

exception pheres._exceptions.JsonableError(msg: str)

Bases: pheres._exceptions.PheresError

Raised on problems with @jsonable when no better sub-exception exists

Variables

msg (str) – explanation of the error

exception pheres._exceptions.JsonAttrError(cls: str, attr: str, detail: str = '', msg: str = "Error in '{cls}' at attribute '{attr}'{detail}")

Bases: pheres._exceptions.JsonableError

Raised on problems with @jsonable due to JsonAttr when no better sub-exception exists

Variables
  • cls (str) – name of the class that raised the error

  • attr (str) – name of the attribute that raised the error

  • msg (str) – explanation of the error

exception pheres._exceptions.JsonAttrValueError(value: Any, cls: str, attr: str, detail: str = '', msg: str = "Invalid JSON value '{value}' in class '{cls}' at attribute '{attr}'")

Bases: pheres._exceptions.JSONValueError, pheres._exceptions.JsonAttrError

Raised when the default value of a json attribute is not a valid json

Variables
  • cls (str) – name of the class that raised the error

  • attr (str) – name of the attribute that raised the error

  • value (Any) – invalid value

  • msg (str) – explanation of the error

exception pheres._exceptions.JsonAttrTypeError(type: TypeHint, value: Any, cls: str, attr: str, detail: str = '', msg: str = "{value} doesn't have type {type} in class '{cls}' at attribute '{attr}'")

Bases: pheres._exceptions.JSONTypeError, pheres._exceptions.JsonAttrError

Raised when the default value of a json attribute doesn’t have the correct type

Variables
  • type – expected type

  • value – invalid value

  • msg (str) – explanation of the error

exception pheres._exceptions.DecodeError(msg: str)

Bases: pheres._exceptions.PheresError

Raised on decoding problem in Pheres when no better exception exists

Variables

msg (str) – explanation of the error

exception pheres._exceptions.TypedJSONDecodeError(msg, doc, pos)

Bases: json.decoder.JSONDecodeError, pheres._exceptions.DecodeError

Raised when the decoded type is not the expected one

Variables
  • doc (Union[str, JSONType]) – JSON document that contains the error

  • pos (Union[int, Tuple[str, ..]]) – position of the error in ‘doc’ can be either an string index, or a list of keys in the json

  • lineno (Optional[int]) – line number of pos

  • colno (Optional[int]) – column number of pos

  • msg (str) – explanation of the error