16
16
from traceback import format_exception
17
17
18
18
from ... import logging
19
- from ...utils .filemanip import savepkl , crash2txt , makedirs
19
+ from ...utils .filemanip import savepkl , crash2txt , makedirs , FileNotFoundError
20
20
21
21
logger = logging .getLogger ('nipype.workflow' )
22
22
@@ -26,17 +26,29 @@ def report_crash(node, traceback=None, hostname=None):
26
26
"""
27
27
name = node ._id
28
28
host = None
29
- if node .result and getattr (node .result , 'runtime' ):
30
- if isinstance (node .result .runtime , list ):
31
- host = node .result .runtime [0 ].hostname
29
+ traceback = traceback or format_exception (* sys .exc_info ())
30
+
31
+ try :
32
+ result = node .result
33
+ except FileNotFoundError :
34
+ traceback += """
35
+
36
+ When creating this crashfile, the results file corresponding
37
+ to the node could not be found.""" .splitlines (keepends = True )
38
+ except Exception as exc :
39
+ traceback += """
40
+
41
+ During the creation of this crashfile triggered by the above exception,
42
+ another exception occurred:\n \n {}.""" .format (exc ).splitlines (keepends = True )
43
+ else :
44
+ if isinstance (result .runtime , list ):
45
+ host = result .runtime [0 ].hostname
32
46
else :
33
- host = node . result .runtime .hostname
47
+ host = result .runtime .hostname
34
48
35
49
# Try everything to fill in the host
36
50
host = host or hostname or gethostname ()
37
51
logger .error ('Node %s failed to run on host %s.' , name , host )
38
- if not traceback :
39
- traceback = format_exception (* sys .exc_info ())
40
52
timeofcrash = strftime ('%Y%m%d-%H%M%S' )
41
53
try :
42
54
login_name = getpass .getuser ()
0 commit comments