@@ -207,27 +207,31 @@ class ThrowablePrinter {
207207 }
208208
209209 val nextIndent = if (hideThrowable) indent else " $indent "
210- throwable.suppressed.forEach {
211- queue + = Work (it, nextIndent, " Suppressed: " , ourStack)
212- }
213210
214211 fun addNextExceptions (prefix : String , causes : Iterable <Throwable >) {
215212 val skipMessage = causes is List <* > && causes.size == 1
213+ val errors = mutableListOf<Work >()
216214 for ((i, cause) in causes.withIndex()) {
217215 val causeIndex = if (skipMessage) " " else " $prefix ${i + 1 } : "
218- queue + = Work (cause, nextIndent, causeIndex, ourStack)
216+ errors + = Work (cause, nextIndent, causeIndex, ourStack)
217+ }
218+ for (work in errors.asReversed()) {
219+ queue.addFirst(work)
219220 }
220221 }
221222 if (throwable is MultiCauseException ) {
222223 addNextExceptions(" Cause" , throwable.causes)
223224 } else {
224225 throwable.cause?.let {
225- queue + = Work (it, nextIndent, " Caused by: " , ourStack)
226+ queue.addFirst( Work (it, nextIndent, " Caused by: " , ourStack) )
226227 }
227228 }
228229 if (throwable is SQLException ) {
229230 addNextExceptions(" Next exception" , Iterable { throwable.iterator() })
230231 }
232+ throwable.suppressed.asList().asReversed().forEach {
233+ queue.addFirst(Work (it, nextIndent, " Suppressed: " , ourStack))
234+ }
231235 val lastFrame = if (hideStacktrace || ourStack?.isEmpty() == null ) {
232236 continue
233237 } else if (causedBy?.isNotEmpty() == true ) {
0 commit comments