ErrorHandler¶
- class ErrorHandler(check_for_warnings=True)[source]
Class to hold error context and having general error functions.
Methods
|
|
Filter out warnings if requested, while adding context to issues. |
|
Gather all issues matching or below a given severity. |
|
|
Format an error based on the parameters, which vary based on what type of error this is. |
Format an error based on the error type. |
|
Remove the last scope from the error context. |
|
Push a new error context to narrow down error scope. |
|
Reset all error context information to defaults. |
|
|
Default error handler if no error of this type was registered. |
Attributes
- ErrorHandler.add_context_and_filter(issues)[source]¶
Filter out warnings if requested, while adding context to issues.
- issues(list):
list: A list containing a single dictionary representing a single error.
- static ErrorHandler.filter_issues_by_severity(issues_list, severity)[source]¶
Gather all issues matching or below a given severity.
- Parameters:
issues_list (list) – A list of dictionaries containing the full issue list.
severity (int) – The level of issues to keep.
- Returns:
A list of dictionaries containing the issue list after filtering by severity.
- Return type:
list
- static ErrorHandler.format_error(error_type, *args, actual_error=None, **kwargs)[source]¶
Format an error based on the parameters, which vary based on what type of error this is.
- Parameters:
error_type (str) – The type of error for this. Registered with @hed_error or @hed_tag_error.
args (args) – Any remaining non keyword args after those required by the error type.
actual_error (str or None) – Code to actually add to report out.
kwargs (kwargs) – The other keyword args to pass down to the error handling func.
- Returns:
A list containing a single dictionary representing a single error.
- Return type:
list
Notes
The actual error is useful for errors that are shared like invalid character.
- static ErrorHandler.format_error_from_context(error_type, error_context, *args, actual_error=None, **kwargs)[source]¶
Format an error based on the error type.
- Parameters:
error_type (str) – The type of error. Registered with @hed_error or @hed_tag_error.
error_context (list) – Contains the error context to use for this error.
args (args) – Any remaining non keyword args.
actual_error (str or None) – Error code to actually add to report out.
kwargs (kwargs) – Keyword parameters to pass down to the error handling func.
- Returns:
A list containing a single dictionary.
- Return type:
list
Notes
Generally the error_context is returned from _add_context_to_errors.
The actual_error is useful for errors that are shared like invalid character.
This can’t filter out warnings like the other ones.
- ErrorHandler.pop_error_context()[source]¶
Remove the last scope from the error context.
Notes
Modifies the error context of this reporter.
- ErrorHandler.push_error_context(context_type, context)[source]¶
Push a new error context to narrow down error scope.
- Parameters:
context_type (ErrorContext) – A value from ErrorContext representing the type of scope.
context (str, int, or HedString) – The main value for the context_type.
Notes
The context depends on the context_type. For ErrorContext.FILE_NAME this would be the actual filename.