From 6f39f8b0b2b023f0b6c96b592f456d32273df114 Mon Sep 17 00:00:00 2001 From: Cail Daley Date: Mon, 6 Jul 2026 08:44:30 +0200 Subject: [PATCH] fix: raise constructed exceptions that were silently discarded Several guard clauses constructed an exception object but never raised it, so the error path fell through instead of failing loud. For the PSFEx interpolation runner (#785) this meant a typo'd MODE skipped all branches, returned (None, None), and let the pipeline record success with no interpolated PSF catalogue. Add the missing `raise` at every site found by grepping src for constructed-but-unraised exceptions: - modules/psfex_interp_runner.py invalid MODE (#785) - modules/mccd_interp_runner.py invalid MODE (x2: VALIDATION + else) - modules/mask_package/mask.py invalid mask type - pipeline/file_handler.py non-str match pattern - pipeline/file_io.py non-ndarray col_data Closes #785 Co-Authored-By: Claude --- src/shapepipe/modules/mask_package/mask.py | 2 +- src/shapepipe/modules/mccd_interp_runner.py | 4 ++-- src/shapepipe/modules/psfex_interp_runner.py | 2 +- src/shapepipe/pipeline/file_handler.py | 2 +- src/shapepipe/pipeline/file_io.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/shapepipe/modules/mask_package/mask.py b/src/shapepipe/modules/mask_package/mask.py index 17e052a6e..38a452c85 100644 --- a/src/shapepipe/modules/mask_package/mask.py +++ b/src/shapepipe/modules/mask_package/mask.py @@ -1070,7 +1070,7 @@ def _exec_WW(self, types="HALO"): self._WW_stdout, self._WW_stderr = execute(cmd) else: - ValueError("Types must be in ['HALO','SPIKE','ALL']") + raise ValueError("Types must be in ['HALO','SPIKE','ALL']") if (self._WW_stderr != "") or (self._rm_reg_stderr != ""): self._err = True diff --git a/src/shapepipe/modules/mccd_interp_runner.py b/src/shapepipe/modules/mccd_interp_runner.py index bf87ea150..82ec7b65f 100644 --- a/src/shapepipe/modules/mccd_interp_runner.py +++ b/src/shapepipe/modules/mccd_interp_runner.py @@ -114,13 +114,13 @@ def mccd_interp_runner( inst.process_me(psf_model_dir, psf_model_pattern, f_wcs_path) elif mode == "VALIDATION": - ValueError( + raise ValueError( "MODE has to be in MULTI-EPOCH or CLASSIC. For validation" + " use MCCD validation runner." ) else: - ValueError("MODE has to be in : [CLASSIC, MULTI-EPOCH]") + raise ValueError("MODE has to be in : [CLASSIC, MULTI-EPOCH]") # No return objects return None, None diff --git a/src/shapepipe/modules/psfex_interp_runner.py b/src/shapepipe/modules/psfex_interp_runner.py index 601ffb0b5..67c21adfc 100644 --- a/src/shapepipe/modules/psfex_interp_runner.py +++ b/src/shapepipe/modules/psfex_interp_runner.py @@ -150,7 +150,7 @@ def psfex_interp_runner( else: # Raise error for invalid run mode - ValueError("MODE has to be in : [CLASSIC, MULTI-EPOCH, VALIDATION]") + raise ValueError("MODE has to be in : [CLASSIC, MULTI-EPOCH, VALIDATION]") # No return objects return None, None diff --git a/src/shapepipe/pipeline/file_handler.py b/src/shapepipe/pipeline/file_handler.py index 9352248de..a2808259f 100644 --- a/src/shapepipe/pipeline/file_handler.py +++ b/src/shapepipe/pipeline/file_handler.py @@ -792,7 +792,7 @@ def _generate_re_pattern(match_pattern): """ if not isinstance(match_pattern, str): - TypeError("Match pattern must be a string.") + raise TypeError("Match pattern must be a string.") chars = [char for char in match_pattern if not char.isalnum()] split_pattern = "|".join(chars).replace(".", r"\.") diff --git a/src/shapepipe/pipeline/file_io.py b/src/shapepipe/pipeline/file_io.py index 0bb8fb763..35f64bc27 100644 --- a/src/shapepipe/pipeline/file_io.py +++ b/src/shapepipe/pipeline/file_io.py @@ -1389,7 +1389,7 @@ def add_col( ) if type(col_data) != np.ndarray: - TypeError("col_data must be a numpy.ndarray") + raise TypeError("col_data must be a numpy.ndarray") if hdu_no is None: hdu_no = self.hdu_no