geofileops.options.set_on_data_error#
- static options.set_on_data_error(action: Literal['raise', 'warn'] | None) _RestoreOriginalHandler#
Set the preferred action to take when a data error occurs.
Possible options are:
“raise” (default if not set): raise an exception.
“warn”: issue a warning and continue.
Note that the “warn” option is only very selectively supported: in many cases, an exception will still be raised.
Remarks:
You can also set the option temporarily by using this function as a context manager.
You can also set the option by directly setting the environment variable GFO_ON_DATA_ERROR to one of “RAISE” or “WARN”.
Added in version 0.11.0.
- Parameters:
action (Literal["raise", "warn"] | None) – The action to take on data error. If None, the option is unset (so the default behavior is used).
Examples
If you want to change the default value of the option in general, you can just call it as a function:
gfo.options.set_on_data_error("warn")
If you want to temporarily change the option, you can use it as a context manager:
with gfo.options.set_on_data_error("warn"): gfo.read_file(...)