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 Pathfrom babregen.jsonout import error_documentfrom babregen.spec import SpecErrorprint(error_document(SpecError("unknown unit 'u'"), Path("."))["error"])
{'path': None, 'line': None, 'message': "unknown unit 'u'", 'suggestion': None}