Skip to content

Commit

Permalink
Trap and print errors from main()
Browse files Browse the repository at this point in the history
  • Loading branch information
areeda committed Dec 26, 2023
1 parent a00d121 commit 62c0e15
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions omicron/cli/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"""
import time
import traceback

from omicron.utils import gps_to_hr, deltat_to_hr

Expand Down Expand Up @@ -805,11 +806,10 @@ def main(args=None):
clean_dirs(run_dir_list)
clean_exit(0, tempfiles)
elif dataduration < minduration:
raise ValueError(
"Segment [%d, %d) is too short (%d < %d), please "
"extend the segment, or shorten the timing parameters."
% (start, end, duration, chunkdur - padding * 2),
)
ermsg = f'Segment [{start}, {end}) is too short ({duration} < {minduration}), ' \

Check warning on line 809 in omicron/cli/process.py

View check run for this annotation

Codecov / codecov/patch

omicron/cli/process.py#L809

Added line #L809 was not covered by tests
f'please; extend the segment, or shorten the timing parameters.'
logger.critical(ermsg)
raise ValueError(ermsg)

Check warning on line 812 in omicron/cli/process.py

View check run for this annotation

Codecov / codecov/patch

omicron/cli/process.py#L811-L812

Added lines #L811 - L812 were not covered by tests

# -- find run segments
# get segments from state vector
Expand Down Expand Up @@ -1478,4 +1478,8 @@ def main(args=None):


if __name__ == "__main__":
main()
try:
main()
except (ValueError, TypeError, OSError, NameError, ArithmeticError, RuntimeError) as ex:
print(ex, file=sys.stderr)
traceback.print_exc(file=sys.stderr)

Check warning on line 1485 in omicron/cli/process.py

View check run for this annotation

Codecov / codecov/patch

omicron/cli/process.py#L1481-L1485

Added lines #L1481 - L1485 were not covered by tests

0 comments on commit 62c0e15

Please sign in to comment.