error_reporter¶
” Support functions for reporting validation errors.
You can scope the formatted errors with calls to push_error_context and pop_error_context.
Functions
|
Return True if there are any errors with a severity of warning. |
|
If error code is a known code, return a documentation url for it. |
|
Return a string with issues list flatted into single string, one per line. |
|
Return a string with issues list as an HTML tree. |
|
Decorator for errors in error handler or inherited classes. |
|
Decorator for errors in error handler or inherited classes. |
|
Utility function to remove any references to tags, strings, etc. |
|
Sort a list of issues by the error context values. |
- check_for_any_errors(issues_list)[source]¶
Return True if there are any errors with a severity of warning.
- create_doc_link(error_code)[source]¶
If error code is a known code, return a documentation url for it.
- Parameters:
error_code (str) – A HED error code.
- Returns:
The URL if it’s a valid code.
- Return type:
url(str or None)
- get_printable_issue_string(issues, title=None, severity=None, skip_filename=True, add_link=False)[source]¶
Return a string with issues list flatted into single string, one per line.
- Parameters:
issues (list) – Issues to print.
title (str) – Optional title that will always show up first if present(even if there are no validation issues).
severity (int) – Return only warnings >= severity.
skip_filename (bool) – If True, don’t add the filename context to the printable string.
add_link (bool) – Add a link at the end of message to the appropriate error if True
- Returns:
A string containing printable version of the issues or ‘’.
- Return type:
str
- get_printable_issue_string_html(issues, title=None, severity=None, skip_filename=True)[source]¶
Return a string with issues list as an HTML tree.
- Parameters:
issues (list) – Issues to print.
title (str) – Optional title that will always show up first if present.
severity (int) – Return only warnings >= severity.
skip_filename (bool) – If True, don’t add the filename context to the printable string.
- Returns:
An HTML string containing the issues or ‘’.
- Return type:
str
- hed_error(error_type, default_severity=1, actual_code=None)[source]¶
Decorator for errors in error handler or inherited classes.
- Parameters:
error_type (str) – A value from error_types or optionally another value.
default_severity (ErrorSeverity) – The default severity for the decorated error.
actual_code (str) – The actual error to report to the outside world.
- hed_tag_error(error_type, default_severity=1, has_sub_tag=False, actual_code=None)[source]¶
Decorator for errors in error handler or inherited classes.
- Parameters:
error_type (str) – A value from error_types or optionally another value.
default_severity (ErrorSeverity) – The default severity for the decorated error.
has_sub_tag (bool) – If True, this error message also wants a sub_tag passed down. eg “This” in “This/Is/A/Tag”
actual_code (str) – The actual error to report to the outside world.
- replace_tag_references(list_or_dict)[source]¶
Utility function to remove any references to tags, strings, etc. from any type of nested list or dict.
Use this if you want to save out issues to a file.
If you’d prefer a copy returned, use replace_tag_references(list_or_dict.copy()).
- Parameters:
list_or_dict (list or dict) – An arbitrarily nested list/dict structure
- sort_issues(issues, reverse=False)[source]¶
Sort a list of issues by the error context values.
- Parameters:
issues (list) – A list of dictionaries representing the issues to be sorted.
reverse (bool, optional) – If True, sorts the list in descending order. Default is False.
- Returns:
The sorted list of issues.
- Return type:
list
Classes
|
Class to hold error context and having general error functions. |