Summary
In src/rhos_ls_mcps/osc.py, the run() method of MyOpenStackShell catches SystemExit as e and raises a ToolError without chaining the original exception, which drops the SystemExit as the cause:
except SystemExit as e:
raise ToolError(
f"OpenStack failed {e.code}: {self.stdout.getvalue() or self.stderr.getvalue()}"
)
This should be changed to:
except SystemExit as e:
raise ToolError(
f"OpenStack failed {e.code}: {self.stdout.getvalue() or self.stderr.getvalue()}"
) from e
Why
Without from e, the original SystemExit is silently discarded as the exception cause. Using raise ... from e preserves the full exception chain, which aids debugging. This is also flagged by Ruff rule B904 (Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling).
Context
Identified during review of PR #11 (Enable ruff and pre-commit). Deferred to a follow-up PR to keep #11 focused on tooling/formatting changes.
Related comment: #11 (comment)
Requested by @lpiwowar.
Summary
In
src/rhos_ls_mcps/osc.py, therun()method ofMyOpenStackShellcatchesSystemExit as eand raises aToolErrorwithout chaining the original exception, which drops theSystemExitas the cause:This should be changed to:
Why
Without
from e, the originalSystemExitis silently discarded as the exception cause. Usingraise ... from epreserves the full exception chain, which aids debugging. This is also flagged by Ruff rule B904 (Within anexceptclause, raise exceptions withraise ... from errorraise ... from Noneto distinguish them from errors in exception handling).Context
Identified during review of PR #11 (Enable ruff and pre-commit). Deferred to a follow-up PR to keep #11 focused on tooling/formatting changes.
Related comment: #11 (comment)
Requested by @lpiwowar.