Skip to main content

jsonout.error_document

jsonout.error_document(exc, root)

The document of records that do not load: the format number and the error.

Parameters

Name Type Description Default
exc Exception The error that stopped the command (a SpecError or another user error). required
root Path The repository root; a path below it is given relative to it. required

Returns

Name Type Description
dict dict format and error with path, line, message and suggestion. The message is the text of the error without its path, line and suggestion; path is None for an error that names no file.

Examples

from pathlib import Path

from babregen.jsonout import error_document
from babregen.spec import SpecError

print(error_document(SpecError("unknown unit 'u'"), Path("."))["error"])
{'path': None, 'line': None, 'message': "unknown unit 'u'", 'suggestion': None}