imod.util.print_if_error#
- imod.util.print_if_error(exception_type: type[BaseException])[source]#
Prints error instead of raising it. Useful for cases when pieces of code are expected to fail, but the script needs to continue. This is a common use-case for examples in the documentation.
- Parameters:
exception_type (Exception) – Exception to accept
Examples
>>> with print_if_error(TypeError): 1 + "a"