Skip to content

Commit

Permalink
Merge pull request #158 from Aratz/issue157
Browse files Browse the repository at this point in the history
Fix solver exception handling
  • Loading branch information
ahellander authored May 30, 2017
2 parents dc779eb + a83bb5e commit ff5a8b5
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions pyurdme/pyurdme.py
Original file line number Diff line number Diff line change
Expand Up @@ -2293,19 +2293,21 @@ def run(self, number_of_trajectories=1, seed=None, input_file=None, loaddata=Fal
handle = subprocess.Popen(urdme_solver_cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
stdout, stderr = handle.communicate()
return_code = handle.wait()
except OSError as e:
print "Error, execution of solver raised an exception: {0}".format(e)
print "urdme_solver_cmd = {0}".format(urdme_solver_cmd)

if return_code != 0:
if self.report_level >= 1:
try:
if return_code != 0:
if self.report_level >= 1:
print stderr, stdout
except Exception as e:
pass
print "urdme_solver_cmd = {0}".format(urdme_solver_cmd)
raise URDMEError("Solver execution failed, return code = {0}".format(return_code))

raise URDMEError(
"Solver execution failed, return code = {0}".format(return_code) +
"\nurdme_solver_cmd = {0}".format(urdme_solver_cmd)
)
except OSError as e:
# Add urdme command to exception message
raise URDMEError(
str(e) +
"\nurdme_solver_cmd = {0}".format(urdme_solver_cmd)
)
print e.args
raise e

#Load the result from the hdf5 output file.
try:
Expand Down

0 comments on commit ff5a8b5

Please sign in to comment.