jsonyx.TruncatedSyntaxError

exception jsonyx.TruncatedSyntaxError(msg, filename, doc, start=0, end=0)

Bases: SyntaxError

Syntax error trucated to fit within the terminal width.

Added in version 2.0.

Parameters:
  • msg (str) – an error message

  • filename (str) – the path to the file

  • doc (str) – a string

  • start (int, default: 0) – the start position

  • end (int, default: 0) – the end position or negative offset

Example:
>>> import jsonyx as json
>>> raise json.TruncatedSyntaxError(
...     "Invalid number", "<string>", "9" * 5000, 0, 5000
... )
Traceback (most recent call last):
  File "<string>", line 1, column 1-5001
    99999999999999999999999999999999999...9999999999999999999999999999999999
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
jsonyx.TruncatedSyntaxError: Invalid number

Tip

You can overwrite the width by setting the COLUMNS environment variable.

See also

jsonyx.format_syntax_error() for formatting the exception.