convnwb.utils.run.catch_error

convnwb.utils.run.catch_error(proceed, name, path, verbose=True, message=None, print_level=0)[source]

Catch a raised error, with the option to save an error log and proceed.

Parameters:
proceedbool

Whether to proceed. If True, the error is saved out, and execution proceeds. If False, the error is raised.

namestr

Name of the file that has an error.

pathstr or Path

Path location to save out the error log

verbosebool, optional, default: True

Whether to print a log of the

messagestr, optional

Message to print out.

print_level{0, 1, 2}

Print level for the printed message. Only used if verbose is True.

Raises:
Error

If proceed is False, then the error is re-raised.

Notes

This function assumes an error has just been raised and should be used within a try/except.