Skip to content

gufo.err.codec

ErrInfo serialization/deserialization primitives.

__q_exception(e)

Convery exception into JSON-serializeable form.

Parameters:

Name Type Description Default
e BaseException

BaseException instance

required

Returns:

Type Description
Dict[str, Any]

Serialized dict

__q_frame_info(fi)

Convert FrameInfo into JSON-serializeable form.

Parameters:

Name Type Description Default
fi FrameInfo

FrameInfo instance

required

Returns:

Type Description
Dict[str, Any]

Serialized dict

__q_source(si)

Convert SourceInfo into JSON-serializeable form.

Parameters:

Name Type Description Default
si SourceInfo

SourceInfo instance

required

Returns:

Type Description
Dict[str, Any]

Serialized dict

__q_var(x)

Convert variable to the JSON-encodable form.

Parameters:

Name Type Description Default
x Any

Exception argument

required

Returns:

Type Description
Union[str, int, float]

JSON-serializeable form of argument

__q_x_class(e)

Get exception class.

Parameters:

Name Type Description Default
e BaseException

Exception instance

required

Returns:

Type Description
str

Serialized exception class name

from_dict(data)

Deserealize Dict to ErrorInfo.

Parameters:

Name Type Description Default
data Dict[str, Any]

Result of to_dict

required

Returns:

Type Description
ErrorInfo

ErrorInfo instance

Raises:

Type Description
ValueError

if required key is missed.

from_json(data)

Deserialize ErrorInfo from JSON string.

Parameters:

Name Type Description Default
data str

JSON string

required

Returns:

Type Description
ErrorInfo

ErrorInfo instance

Raises:

Type Description
ValueError

if required key is missed.

to_dict(info)

Serialize ErrorInfo to a dict of primitive types.

Parameters:

Name Type Description Default
info ErrorInfo

ErrorInfo instance.

required

Returns:

Type Description
Dict[str, Any]

Dict of primitive types (str, int, float).

to_json(info)

Serialize ErrorInfo to JSON string.

Parameters:

Name Type Description Default
info ErrorInfo

ErrorInfo instance.

required

Returns:

Type Description
str

json-encoded string.