Skip to content

Commit

Permalink
Only use logger.exception for unexpected exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
eivindjahren committed Oct 4, 2024
1 parent 1c82874 commit 3e934b6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/ert/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import ert.shared
from _ert.threading import set_signal_handler
from ert.cli.main import ErtCliError, ErtTimeoutError, run_cli
from ert.cli.main import ErtCliError, run_cli
from ert.config import ConfigValidationError, ErtConfig, lint_file
from ert.logging import LOGGING_CONFIG
from ert.mode_definitions import (
Expand Down Expand Up @@ -681,12 +681,12 @@ def main() -> None:
with ErtPluginContext(logger=logging.getLogger()) as context:
logger.info(f"Running ert with {args}")
args.func(args, context.plugin_manager)
except (ErtCliError, ErtTimeoutError) as err:
logger.exception(str(err))
except ErtCliError as err:
logger.debug(str(err))
sys.exit(str(err))
except ConfigValidationError as err:
err_msg = err.cli_message()
logger.exception(err_msg)
logger.debug(err_msg)
sys.exit(err_msg)
except BaseException as err:
logger.exception(f'ERT crashed unexpectedly with "{err}"')
Expand Down
4 changes: 0 additions & 4 deletions src/ert/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ class ErtCliError(Exception):
pass


class ErtTimeoutError(Exception):
pass


def run_cli(args: Namespace, plugin_manager: Optional[ErtPluginManager] = None) -> None:
ert_dir = os.path.abspath(os.path.dirname(args.config))
os.chdir(ert_dir)
Expand Down
10 changes: 5 additions & 5 deletions src/ert/gui/tools/plot/plot_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def __init__(self, config_file: str, parent: Optional[QWidget]):
self._api = PlotApi()
self._key_definitions = self._api.all_data_type_keys()
except (RequestError, TimeoutError) as e:
logger.exception(e)
logger.exception(f"plot api request failed: {e}")
open_error_dialog("Request failed", str(e))
self._key_definitions = []
QApplication.restoreOverrideCursor()
Expand Down Expand Up @@ -191,7 +191,7 @@ def updatePlot(self, layer: Optional[int] = None) -> None:
ensemble.id, key
)
except (RequestError, TimeoutError) as e:
logger.exception(e)
logger.exception(f"plot api request failed: {e}")
open_error_dialog("Request failed", f"{e}")

observations = None
Expand All @@ -201,7 +201,7 @@ def updatePlot(self, layer: Optional[int] = None) -> None:
[ensembles.id for ensembles in selected_ensembles], key
)
except (RequestError, TimeoutError) as e:
logger.exception(e)
logger.exception(f"plot api request failed: {e}")
open_error_dialog("Request failed", f"{e}")

std_dev_images: Dict[str, npt.NDArray[np.float32]] = {}
Expand All @@ -221,7 +221,7 @@ def updatePlot(self, layer: Optional[int] = None) -> None:
key, ensemble.id, layer
)
except (RequestError, TimeoutError) as e:
logger.exception(e)
logger.exception(f"plot api request failed: {e}")
open_error_dialog("Request failed", f"{e}")
else:
plot_widget.showLayerWidget.emit(False)
Expand All @@ -241,7 +241,7 @@ def updatePlot(self, layer: Optional[int] = None) -> None:
)

except (RequestError, TimeoutError) as e:
logger.exception(e)
logger.exception(f"plot api request failed: {e}")
open_error_dialog("Request failed", f"{e}")
plot_context.history_data = None

Expand Down

0 comments on commit 3e934b6

Please sign in to comment.