public static void addThrowableAndCauses ( List < ThrowableDTO > exceptions , Throwable exception ) { if ( exception != null ) { ThrowableDTO dto = new ThrowableDTO ( exception ) ; exceptions . add ( dto ) ; Throwable cause = exception . getCause ( ) ; if ( cause != null && cause != exception ) { addThrowableAndCauses ( exceptions , cause ) ; } } }
Adds the exception and all of the causes to the given list of exceptions