File tree Expand file tree Collapse file tree
lib/src/main/kotlin/org/veupathdb/lib/compute/platform/intern/minio Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -40,25 +40,25 @@ internal object MinIOHax {
4040 */
4141 context(log: Logger )
4242 fun <T > withRetries (actionMsg : () -> String , action : () -> T ): T {
43- var lastError: S34KError ? = null
43+ val errors = ArrayList <S34KError >(RetryCount )
44+ var msg: String? = null
4445
4546 for (i in 1 .. RetryCount ) {
4647 try {
4748 return action()
4849 } catch (e: S34KError ) {
49- log.warn(" failed {} time(s) to {}" , i, actionMsg())
50-
51- if (lastError != null )
52- e.addSuppressed(lastError)
53-
54- lastError = e
50+ if (msg == null )
51+ msg = actionMsg()
5552
53+ log.warn(" failed {} time(s) to {}" , i, msg)
54+ errors.add(e)
5655 sleep()
5756 }
5857 }
5958
60- log.error(" failed {} time(s) to {}" , RetryCount , actionMsg())
61- throw lastError!!
59+ log.error(" failed {} time(s) to {}" , RetryCount , msg)
60+ throw errors.last()
61+ .apply { errors.forEach { if (it != this ) addSuppressed(it) } }
6262 }
6363
6464 /* *
You can’t perform that action at this time.
0 commit comments