jsonyx.format_syntax_error

jsonyx.format_syntax_error(exc)[source]

Format a truncated syntax error.

Parameters:

exc (TruncatedSyntaxError) – a truncated syntax error

Returns:

list[str] – a list of strings, each ending in a newline

Example:
>>> import jsonyx as json
>>> try:
...     json.loads("[,]")
... except json.JSONSyntaxError as exc:
...     print("Traceback (most recent call last):")
...     print(end="".join(json.format_syntax_error(exc)))
...
Traceback (most recent call last):
  File "<string>", line 1, column 2
    [,]
     ^
jsonyx.JSONSyntaxError: Expecting value

Note

Don’t use traceback.format_exception_only(), it displays less information.