scenic.core.errors

Common exceptions and error handling.

Summary of Module Members

Module Attributes

showInternalBacktrace

Whether or not to include Scenic's innards in backtraces.

postMortemDebugging

Whether or not to do post-mortem debugging of uncaught exceptions.

postMortemRejections

Whether or not to do "post-mortem" debugging of rejected scenes/simulations.

hiddenFolders

Folders elided from backtraces when showInternalBacktrace is false.

Functions

callBeginningScenicTrace

Call the given function, starting the Scenic backtrace at that point.

displayScenicException

Print a Scenic exception, cleaning up the traceback if desired.

excepthook

getText

Attempt to recover the text of an error from the original Scenic file.

includeFrame

optionallyDebugRejection

saveErrorLocation

Exceptions

ASTParseError

Parse error occuring during modification of the Python AST.

InconsistentScenarioError

Error for scenarios with inconsistent requirements.

InvalidScenarioError

Error raised for syntactically-valid but otherwise problematic Scenic programs.

PythonParseError

Parse error occurring during Python parsing or compilation.

RuntimeParseError

A Scenic parse error generated during execution of the translated Python.

ScenicError

An error produced during Scenic compilation, scene generation, or simulation.

ScenicSyntaxError

An error produced by attempting to parse an invalid Scenic program.

TokenParseError

Parse error occurring during token translation.

Member Details

showInternalBacktrace = False

Whether or not to include Scenic’s innards in backtraces.

Set to True by default so that any errors during import of the scenic module will get full backtraces; the scenic module’s __init__.py sets it to False.

postMortemDebugging = False

Whether or not to do post-mortem debugging of uncaught exceptions.

postMortemRejections = False

Whether or not to do “post-mortem” debugging of rejected scenes/simulations.

hiddenFolders

Folders elided from backtraces when showInternalBacktrace is false.

exception ScenicError[source]

Bases: Exception

An error produced during Scenic compilation, scene generation, or simulation.

exception ScenicSyntaxError[source]

Bases: ScenicError

An error produced by attempting to parse an invalid Scenic program.

This is intentionally not a subclass of SyntaxError so that pdb can be used for post-mortem debugging of the parser. Our custom excepthook below will arrange to still have it formatted as a SyntaxError, though.

exception TokenParseError(tokenOrLine, filename, message)[source]

Bases: ScenicSyntaxError

Parse error occurring during token translation.

exception PythonParseError(exc)[source]

Bases: ScenicSyntaxError

Parse error occurring during Python parsing or compilation.

exception ASTParseError(node, message, filename)[source]

Bases: ScenicSyntaxError

Parse error occuring during modification of the Python AST.

exception RuntimeParseError(msg, loc=None)[source]

Bases: ScenicSyntaxError

A Scenic parse error generated during execution of the translated Python.

exception InvalidScenarioError[source]

Bases: ScenicError

Error raised for syntactically-valid but otherwise problematic Scenic programs.

exception InconsistentScenarioError(line, message)[source]

Bases: InvalidScenarioError

Error for scenarios with inconsistent requirements.

displayScenicException(exc, seen=None)[source]

Print a Scenic exception, cleaning up the traceback if desired.

If showInternalBacktrace is False, this hides frames inside Scenic itself.

callBeginningScenicTrace(func)[source]

Call the given function, starting the Scenic backtrace at that point.

This function is just a convenience to make Scenic backtraces cleaner when running Scenic programs from the command line.

getText(filename, lineno, line='', offset=0, end_offset=None)[source]

Attempt to recover the text of an error from the original Scenic file.