module documentation

License: Apache 2.0

VERSION INFO:

  $Repo: async_example_program
$Author: Anders Wiklund
  $Date: 2023-10-14 12:00:19
   $Rev: 37
Function error_message_of Return a populated ErrorMessage.
Function error_text_of Return exception context and error text.
Function get_exception_context Return Exception context (filename, location and line number).
Function has_traceback_frames Return exception traceback frame status.
Function traceback_text_of Return exception traceback as a string.
Constant EXTERNAL Root paths to third party and standard python modules (virtual or not).
Constant SUBJECT Subject template text based on error state.
def error_message_of(error: Exception, program: str, state: str, include_traceback: bool = True) -> dict: (source)

Return a populated ErrorMessage.

When include_traceback=True, an exception traceback is attached to the description.

Parameters
error:ExceptionCurrent exception.
program:strCurrent program.
state:strCurrent error state.
include_traceback:boolInclude traceback status (default is True).
Returns
dictA populated ErrorMessage.
def error_text_of(error: Exception, include_traceback: bool = False, extra: Optional[str] = None) -> str: (source)

Return exception context and error text.

When include_traceback=True, an exception traceback is appended to the text.

When the extra parameter is specified, that text is inserted after the location and before the reason.

The logical structure of the error test is:

<location> [<extra>] <reason> [<BR><traceback>]
Parameters
error:ExceptionCurrent exception.
include_traceback:boolInclude traceback status.
extra:Optional[str]Additional error text.
Returns
strException context and error text (+ eventual traceback).
def get_exception_context() -> str: (source)

Return Exception context (filename, location and line number).

Traverse the traceback stack from the last frame backwards to the first since that starts closest to the raised exception, and find the first frame where the filename isn't found in the standard python library or from any of the imported site-packages.

Then you have found what triggered the exception in our own code.

Returns
strError context ("<filename>[<location>(<lineno>)]").
def has_traceback_frames(error: Exception) -> bool: (source)

Return exception traceback frame status.

Parameters
error:ExceptionCurrent exception.
Returns
boolDoes exception contain traceback frames?.
def traceback_text_of(error: Exception) -> str: (source)

Return exception traceback as a string.

Parameters
error:ExceptionCurrent exception.
Returns
strException traceback as a string.
EXTERNAL = (source)

Root paths to third party and standard python modules (virtual or not).

Value
set([sys.prefix, sys.base_prefix])

Subject template text based on error state.

Value
{'PROG': 'Program {0} processing failure on {1}',
 'FATAL': 'Program {0} crashed unexpectedly on {1}',
 'DUMP': 'Program {0} processing failed unexpectedly on {1}'}