Repository navigation
Raise exceptions instead of calling sys.exit in decommutator - #55
Merged
Merged
Conversation
added 6 commits
October 5, 2026 20:26
Collaborator
Author
|
@namurphy Ready for review. All |
namurphy
reviewed
Oct 6, 2026
Comment on lines
+83
to
+84
| msg = f"Could not read in file: {path}" | ||
| raise RuntimeError(msg) from exc |
Member
There was a problem hiding this comment.
Nice. This code follows the best practice of defining long exception messages prior to raising an exception with them. When this is not done, exceptions tracebacks get horrible-er.
namurphy
reviewed
Oct 6, 2026
namurphy
reviewed
Oct 6, 2026
namurphy
reviewed
Oct 6, 2026
| msg = f"Could not check existence of or delete L1 CDF file: {l1path}" | ||
| statusmsg( | ||
| "\n***ERROR*** [swp_spc_l02l1] Could not check existence/delete L1 CDF file path. Exiting...\n", | ||
| f"***ERROR*** [swp_spc_l02l1] {msg}", |
Member
There was a problem hiding this comment.
🎗️ After switching to using logging (#50), we can replace the ***ERROR*** messages with a logger.error("...") so that users can have finer control over the verbosity that gets reported. That would be better in a later pull request, though.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #45
Replaces
sys.exitcalls in the decommutator with raised exceptions that describe what went wrong and which file was involved.sys.exit()with no argument exits with code 0, so failures looked like successes to anything running these scripts.main.pyis unchanged.Each
except:that led to an exit becomesexcept Exception as exc:and usesraise ... from exc, so the original error (for example,FileNotFoundError) stays in the traceback.Progress
ccsds_reader_pipeline.pyfile2bytestr: input file cannot be read →RuntimeErrorswp_spc_l02l1.py(main)RuntimeErrorRuntimeErrorRuntimeErroroverwriteis not set →FileExistsErrorRuntimeErrorThis is not the final form: more specific exception classes can be added later, as noted in the issue.