scenic.core.errors

Common exceptions and error handling.

Summary of Module Members

Module Attributes

verbosityLevel

Verbosity level.

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

setDebuggingOptions

Configure Scenic's debugging options.

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.

ParseCompileError

Error occurring during Scenic/Python parsing or compilation.

PythonCompileError

Error occuring during Python compilation of translated Scenic code.

ScenicError

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

ScenicParseError

Error occuring during Scenic parsing or compilation.

ScenicSyntaxError

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

SpecifierError

Error for illegal uses of specifiers.

Member Details

setDebuggingOptions(*, verbosity=0, fullBacktrace=False, debugExceptions=False, debugRejections=False)[source]

Configure Scenic’s debugging options.

Parameters:
  • verbosity (int) – Verbosity level. Zero by default, although the command-line interface uses 1 by default. See the --verbosity option for the allowed values.

  • fullBacktrace (bool) – Whether to include Scenic’s innards in backtraces (like the -b command-line option).

  • debugExceptions (bool) – Whether to use pdb for post-mortem debugging of uncaught exceptions (like the --pdb option).

  • debugRejections (bool) – Whether to enter pdb when a scene or simulation is rejected (like the --pdb-on-reject option).

verbosityLevel = 0

Verbosity level. See --verbosity for the allowed values.

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 ParseCompileError(exc)[source]

Bases: ScenicSyntaxError

Error occurring during Scenic/Python parsing or compilation.

exception ScenicParseError(exc)[source]

Bases: ParseCompileError

Error occuring during Scenic parsing or compilation.

exception PythonCompileError(exc)[source]

Bases: ParseCompileError

Error occuring during Python compilation of translated Scenic code.

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

Bases: ScenicSyntaxError

Parse error occuring during modification of the Python AST.

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.

exception SpecifierError[source]

Bases: ScenicError

Error for illegal uses of specifiers.

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.