colawater.lib.error
#
Functions for handling errors from arcpy.
Examples
import arcpy
@fallible
def foo(bar: str) -> str:
if magic_variable:
raise arcpy.ExecuteError # Caught and handled by decorator
elif more_magic:
raise SystemError # Also caught
elif magic_again:
raise RuntimeError # Catches this too!
return bar # This is returned normally
Module Contents#
Functions#
|
Wraps the decorated function in a try-catch block that handles |
- colawater.lib.error.fallible(f: Callable[Ellipsis, _T]) Callable[Ellipsis, _T | NoReturn] #
Wraps the decorated function in a try-catch block that handles
SystemError
/RuntimeError
andException
Dumps the tool summary and prints a relevant error message depending on the exception.
Note
The default error message output in ArcGIS often says ‘RuntimeError’ when a SystemError occurs.
- Returns:
The return value of the wrapped function. Or, if an exception is caught, an
ExecuteError
is raised, and the function does not return.- Return type:
Union[_T, NoReturn]
- Raises:
ExecuteError – An exception was caught, so this was raised in its place.