AgentError#

class scikitplot.agent.AgentError(code, message, details=<factory>)[source]#

One error, as recorded in a run’s state and audit trail.

Parameters:
codeErrorCode

What went wrong.

messagestr

A sentence a person can act on.

detailsmapping, default={}

JSON-compatible facts (the gate, the limit, the tool, …).

Raises:
TypeError

If code is not an ErrorCode (or its value) or message is not a string.

Parameters:

Examples

>>> from scikitplot.agent import AgentError, ErrorCode
>>> err = AgentError(ErrorCode.SCOPE_DENIED, "needs 'corpus:read'")
>>> err.to_dict()["code"]
'scope_denied'
>>> AgentError.from_dict(err.to_dict()) == err
True
code: ErrorCode[source]#
details: Mapping[str, Any][source]#
classmethod from_dict(data)[source]#

Rebuild an error written by to_dict.

Parameters:

data (Mapping[str, Any])

Return type:

AgentError

message: str[source]#
to_dict()[source]#

Return a JSON-compatible mapping.

Return type:

dict[str, Any]