Java examples for Reflection:Annotation
Returns the cause of the specified exception.
/*/* w ww. j a va2s .c om*/ * Copyright (c) 2015-2016 QuartzDesk.com. * Licensed under the MIT license (https://opensource.org/licenses/MIT). */ //package com.java2s; import java.sql.SQLException; public class Main { /** * Returns the cause of the specified exception. * * @param t an exception. * @return the cause. */ public static Throwable getCause(Throwable t) { // SQLException does not use "standard" cause chaining...grrr if (t instanceof SQLException) { return ((SQLException) t).getNextException(); } else { return t.getCause(); } } }