File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 33import logging
44import time
55
6+ from typing import Optional
7+
68from teuthology .config import config
79from teuthology .exceptions import MaxWhileTries
810
@@ -120,7 +122,7 @@ def _make_error_msg(self):
120122 )
121123 return msg
122124
123- def __call__ (self ):
125+ def __call__ (self , last_exception : Optional [ Exception ] = None ):
124126 self .counter += 1
125127 if self .counter == 1 :
126128 return True
@@ -131,7 +133,7 @@ def must_stop():
131133 (self .timeout == 0 and must_stop ())):
132134 error_msg = self ._make_error_msg ()
133135 if self ._raise :
134- raise MaxWhileTries (error_msg )
136+ raise MaxWhileTries (error_msg , last_exception )
135137 else :
136138 log .warning (error_msg )
137139 return False
Original file line number Diff line number Diff line change 1+ from typing import Optional
2+
13class BranchNotFoundError (ValueError ):
24 def __init__ (self , branch , repo = None ):
35 self .branch = branch
@@ -200,7 +202,14 @@ class SkipJob(Exception):
200202
201203
202204class MaxWhileTries (Exception ):
203- pass
205+ def __init__ (self , message : str = '' , last_exception : Optional [Exception ] = None ):
206+ self .message = message
207+ self .last_exception = last_exception
208+
209+ def __str__ (self ):
210+ if self .last_exception :
211+ return f"{ self .message } (last exception: { self .last_exception } )"
212+ return self .message
204213
205214
206215class ConsoleError (Exception ):
You can’t perform that action at this time.
0 commit comments