Skip to content
Snippets Groups Projects
Commit 48797394 authored by David Schäfer's avatar David Schäfer
Browse files

better error messaged on error_policy 'raise'

parent e4bec4e3
No related branches found
No related tags found
No related merge requests found
varname;test;plot
SM1;range(min=10, max=60);False
SM2;missing(nodata=NAN);False
SM2;missing(nodata=nan);False
SM2;range(min=10, max=60);False
SM2;spikes_simpleMad(winsz="30d", z=3.5);True
# SM2;harmonize_shift2Grid(freq="15Min");False
......
......@@ -60,16 +60,15 @@ def _checkInput(data, flags, flagger):
# NOTE: do not test columns as they not necessarily must be the same
def _handleErrors(err, configrow, test, policy):
def _handleErrors(exc, configrow, test, policy):
line = configrow[Fields.LINENUMBER]
msg = f" config, line {line}, test: `{test}` failed with `{type(err).__name__}: {err}`"
msg = f"config, line {line}, test: '{test}' failed with:\n{type(exc).__name__}: {exc}"
if policy == "ignore":
logging.debug(msg)
return False
elif policy == "warn":
logging.warning(msg)
return False
return True
else:
raise Exception(msg)
def _setup():
......@@ -148,8 +147,7 @@ def runner(
nodata=nodata,
)
except Exception as e:
if _handleErrors(e, configrow, func, error_policy):
raise e
_handleErrors(e, configrow, func, error_policy)
continue
if configrow[Fields.PLOT]:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment