diff --git a/mlair/run_modules/pre_processing.py b/mlair/run_modules/pre_processing.py index 68164b6fa3c6b95727f634baebd40e988482abd5..9d44ce0b0e8d7b0bac9c188c697a5e65ab67df4c 100644 --- a/mlair/run_modules/pre_processing.py +++ b/mlair/run_modules/pre_processing.py @@ -5,6 +5,7 @@ __date__ = '2019-11-25' import logging import os +import traceback from typing import Tuple import multiprocessing import requests @@ -337,6 +338,15 @@ def f_proc(data_handler, station, name_affix, store, **kwargs): try: res = data_handler.build(station, name_affix=name_affix, store_processed_data=store, **kwargs) except (AttributeError, EmptyQueryResult, KeyError, requests.ConnectionError, ValueError) as e: - logging.info(f"remove station {station} because it raised an error: {e}") + formatted_lines = traceback.format_exc().splitlines() + logging.info( + f"remove station {station} because it raised an error: {e} -> {' | '.join(f_inspect_error(formatted_lines))}") res = None return res, station + + +def f_inspect_error(formatted): + for i in range(len(formatted) - 1, -1, -1): + if "mlair/mlair" not in formatted[i]: + return formatted[i - 3:i] + return formatted[-3:0]