1616from traceback import format_exception
1717
1818from ... import logging
19- from ...utils .filemanip import savepkl , crash2txt , makedirs
19+ from ...utils .filemanip import savepkl , crash2txt , makedirs , FileNotFoundError
2020
2121logger = logging .getLogger ('nipype.workflow' )
2222
@@ -26,17 +26,29 @@ def report_crash(node, traceback=None, hostname=None):
2626 """
2727 name = node ._id
2828 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
3246 else :
33- host = node . result .runtime .hostname
47+ host = result .runtime .hostname
3448
3549 # Try everything to fill in the host
3650 host = host or hostname or gethostname ()
3751 logger .error ('Node %s failed to run on host %s.' , name , host )
38- if not traceback :
39- traceback = format_exception (* sys .exc_info ())
4052 timeofcrash = strftime ('%Y%m%d-%H%M%S' )
4153 try :
4254 login_name = getpass .getuser ()
0 commit comments