mirar.errors package
Central module for handling errors during processing.
In general, the philosophy is that DataBatch objects
should be processed, unless an error occurs.
If there is an error, then an ErrorReport
should be created for the error.
These ErrorReport objects should be collated in
a single ErrorStack object.
After processing is complete, the ErrorStack can
then be used to summarise these errors, and track which images failed.
Ideally, it should be understood why the processing failed for a given image. Therefore the code distinguishes between internal errors which were deliberately raised, and external errors which were not deliberately raised.
In general, all internal errors should inherit from the
mirar.errors.exceptions.BaseProcessorError class.
If the error is critical (i.e the image should not be processed further), then an
error should be raised which inherits from the
mirar.errors.exceptions.ProcessorError class.
If the error is non-critical (so processing should continue), then an
error should be raised which inherits from the
mirar.errors.exceptions.NoncriticalProcessingError class. In that case,
processing will continue but the error will be logged.
Submodules
mirar.errors.error_report module
Module for ErrorReport objects.
An ErrorReport object summarises a single error
raised by the code.
- class mirar.errors.error_report.ErrorReport(error: Exception, processor_name: str, contents: list[str] | list[Path])[source]
Bases:
objectClass representing a single error raised during processing
- generate_full_traceback() str[source]
Returns a verbose string summarising the error
- Returns:
String
- generate_log_message() str[source]
Returns a human-readable string describing high-livel details about the error.
- Returns:
String summary
mirar.errors.error_stack module
Module for ErrorStack objects.
A ErrorStack object will contain a list of
ErrorReport objects, and can correspond to
multiple errors raised by the code.
- class mirar.errors.error_stack.ErrorStack(reports: list[ErrorReport] | None = None)[source]
Bases:
objectContainer class to hold multiple
ErrorReportobjects- add_report(report: ErrorReport)[source]
Adds a new ErrorReport
- Parameters:
report – ErrorReport to add
- Returns:
None
- get_all_reports() list[ErrorReport][source]
Returns the full list of error reports (both critical and non-critical).
- Returns:
list of ErrorReports
mirar.errors.exceptions module
Module containing common exceptions or base exceptions for the code.
In general, all internal errors should inherit from the
mirar.errors.exceptions.BaseProcessorError class.
If the error is critical (i.e the image should not be processed further), then an
error should be raised which inherits from the
mirar.errors.exceptions.ProcessorError class.
If the error is non-critical (so processing should continue), then an
error should be raised which inherits from the
mirar.errors.exceptions.NoncriticalProcessingError class. In that case,
processing will continue but the error will be logged.
- exception mirar.errors.exceptions.BaseProcessorError[source]
Bases:
ExceptionBase exception, from which all internal exceptions should derive
- exception mirar.errors.exceptions.ImageNotFoundError[source]
Bases:
ProcessorError,FileNotFoundErrorBase class for all exceptions concerning missing images
- exception mirar.errors.exceptions.NoncriticalProcessingError[source]
Bases:
BaseProcessorErrorBase class for all non-critical internal exceptions
- exception mirar.errors.exceptions.ProcessorError[source]
Bases:
BaseProcessorErrorBase class for all critical internal exceptions