Skip to content

Commit 296f5fd

Browse files
authored
Merge pull request #2139 from willend/main
Improved error-handling in mccode.py
2 parents 78b01a5 + 0eaf13e commit 296f5fd

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

docs/pull_request_template.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
### Free-form text area
22
_Please describe what your PR is adding in terms of features or bugfixes:_
33

4-
Underline that only _relevant parts_ of the checklist needs to be filled in.
4+
55

66
--------------
77
### Development OS / boundary conditions
@@ -46,7 +46,7 @@ _Please describe what OS you developed and tested your additions on, and if any
4646
* [ ] I have indicated the issue number here:
4747
* [ ] I have added documentation for the fix and possible side effects
4848
* ### My contribution contains something else
49-
* [x] Explanation is added in free form text above or below the checklist
49+
* [ ] Explanation is added in free form text above or below the checklist
5050

5151
--------------
5252

tools/Python/mcrun/mccode.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,14 @@ def x_path(file):
154154
trace='-t'
155155
if options.no_trace:
156156
trace='--no-trace'
157-
if self.options.I is not None:
158-
Process(mccode_bin_abspath).run([trace, '-o', self.cpath, self.path, '-I', self.options.I])
159-
else:
160-
Process(mccode_bin_abspath).run([trace, '-o', self.cpath, self.path])
157+
try:
158+
if self.options.I is not None:
159+
Process(mccode_bin_abspath).run([trace, '-o', self.cpath, self.path, '-I', self.options.I])
160+
else:
161+
Process(mccode_bin_abspath).run([trace, '-o', self.cpath, self.path])
162+
except:
163+
LOG.error('Code generation failed for instrument %s using code generator %s', self.path, mccode_bin_abspath)
164+
exit(-1)
161165
else:
162166
if self.options.I is not None:
163167
Process(mccode_bin_abspath).run(['--no-main', '-o', self.cpath, self.path, '-I', self.options.I])
@@ -314,16 +318,23 @@ def x_path(file):
314318
# Lint or compile?
315319
if options.c_lint is not None:
316320
args = [self.cpath] + lexer.split(mccode_config.compilation['CLINTERFLAGS'])
317-
Process(lexer.quote(mccode_config.compilation['CLINT'])).run(args)
318-
LOG.info('End of linting %s', self.cpath)
321+
try:
322+
Process(lexer.quote(mccode_config.compilation['CLINT'])).run(args)
323+
LOG.info('End of linting %s', self.cpath)
324+
except:
325+
LOG.error('Linting failed on %s - you may need to install the %s package?', self.cpath, mccode_config.compilation['CLINT'])
319326
exit()
320327
else:
321328
# Final assembly of compiler commandline
322329
if not "cl.exe" in mccode_config.compilation['CC'].lower():
323330
args = ['-o', self.binpath, self.cpath] + lexer.split(cflags)
324331
else:
325332
args = [self.cpath] + lexer.split(cflags)
326-
Process(lexer.quote(options.cc)).run(args)
333+
try:
334+
Process(lexer.quote(options.cc)).run(args)
335+
except:
336+
LOG.error('Compilation failed for %s using compiler %s', self.cpath, options.cc)
337+
exit(-1)
327338

328339
def run(self, pipe=False, extra_opts=None, override_mpi=None):
329340
''' Run simulation '''

0 commit comments

Comments
 (0)