Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only use logger.exception for unexpected exceptions #8876

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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