web/src/main/java/org/springframework/security/web/util/ThrowableAnalyzer.java
public final Throwable getFirstThrowableOfType(
			Class<? extends Throwable> throwableType, Throwable[] chain) {
		if (chain != null) {
			for (Throwable t : chain) {
				if ((t != null) && throwableType.isInstance(t)) {
					return t;
				}
			}
		}

		return null;
	}
public final Throwable getFirstThrowableOfType(
			Class<? extends Throwable> throwableType, Throwable[] chain) {
		if (chain != null) {
			for (Throwable t : chain) {
				if ((t != null) && throwableType.isInstance(t)) {
					return t;
				}
			}
		}

		return null;
	}
Returns the first throwable from the passed in array that is assignable to the
provided type. A returned instance is safe to be cast to the specified type.
<p>
If the passed in array is null or empty this method returns <code>null</code>.

@param throwableType the type to look for
@param chain the array (will be processed in element order)
@return the found <code>Throwable</code>, <code>null</code> if not found

@throws IllegalArgumentException if the provided type is <code>null</code> or no
subclass of <code>Throwable</code>