001// Licensed under the MIT license. See LICENSE file in the project root for full license information.
002
003package de.bytefish.pgbulkinsert.util;
004
005
006public class ExceptionUtils {
007
008    private ExceptionUtils() {}
009
010    public static Throwable getRootCause(Throwable t) {
011        if (t == null) {
012            return null;
013        }
014
015        Throwable rootCause = null;
016        Throwable cause = t.getCause();
017
018        // Now get to the Inner-Most Cause:
019        while (cause != null && cause != rootCause) {
020            rootCause = cause;
021            cause = cause.getCause();
022        }
023
024        return rootCause;
025    }
026}