Skip to content
This repository has been archived by the owner on Dec 16, 2023. It is now read-only.

Commit

Permalink
Merge pull request #46 from ktbolt/0D-Solver-crash-not-detected_922
Browse files Browse the repository at this point in the history
Add try/catch block to catch internal error and return status back to…
  • Loading branch information
ktbolt committed Sep 14, 2021
2 parents 75fb115 + 1fb19ad commit 53eefab
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions svzerodsolver/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1009,14 +1009,24 @@ def run_from_c(*args, **kwargs):
# This is need by 'argparse.ArgumentParser()', sys.argv[] must be defined..
sys.argv = [ "svZeroDSolver" ]

# Define command-line parameters.
parser = create_parser()
# Set solver return status.
msg = "Status: OK\n"

try:
# Define command-line parameters.
parser = create_parser()

# Set the values for command-line parameters.
cmd_line_args = parser.parse_args(args)

# Run the 0D solver.
run_simulation(cmd_line_args)

# Set the values for command-line parameters.
cmd_line_args = parser.parse_args(args)
except Exception as e:
msg = "Status: ERROR\n"
msg += "ERROR: " + str(e) + "\n"

# Run the 0D solver.
run_simulation(cmd_line_args)
return msg

def create_parser():
"""Create a command-line parser.
Expand Down

0 comments on commit 53eefab

Please sign in to comment.