当前位置: 首页>>代码示例>>Java>>正文


Java ExceptionUtils.getThrowables方法代码示例

本文整理汇总了Java中org.apache.commons.lang.exception.ExceptionUtils.getThrowables方法的典型用法代码示例。如果您正苦于以下问题:Java ExceptionUtils.getThrowables方法的具体用法?Java ExceptionUtils.getThrowables怎么用?Java ExceptionUtils.getThrowables使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang.exception.ExceptionUtils的用法示例。


在下文中一共展示了ExceptionUtils.getThrowables方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isCausedByTimeoutException

import org.apache.commons.lang.exception.ExceptionUtils; //导入方法依赖的package包/类
/**
 * <p>Checks if the throwable was caused by timeout exception.</p>
 * <b>This method has been tested for Oracle and MySQL only and might not work
 * for other DB engines.</b>
 *
 * @param throwable to check
 * @return true if the throwable is caused by a timeout, false otherwise
 */
public boolean isCausedByTimeoutException(Throwable throwable) {
  // Valid test for Oracle timeout exception and some (not all!) MySQL
  // exceptions.
  if (ExceptionUtils.indexOfType(throwable, SQLTimeoutException.class) != -1) {
    return true;
  }
  // MySQL database has two timeout exceptions in two packages. One of them
  // doesn't extend SQLTimeoutException but only SQLException. It is therefore
  // necessary to do ugly name check...
  for (Throwable causeThrowable : ExceptionUtils.getThrowables(throwable)) {
    if (MYSQL_TIMEOUT_EXCEPTION_NAME.equals(causeThrowable.getClass().getSimpleName())) {
      return true;
    }
  }
  return false;
}
 
开发者ID:alfasoftware,项目名称:morf,代码行数:25,代码来源:DatabaseExceptionHelper.java

示例2: isLockingException

import org.apache.commons.lang.exception.ExceptionUtils; //导入方法依赖的package包/类
private static boolean isLockingException(final Throwable t, final boolean recurse) {
    if (t instanceof LockingException || t instanceof PessimisticLockException) {
        return true;
    }
    if (t instanceof SQLException) {
        final SQLException e = (SQLException) t;
        return e.getErrorCode() == ER_LOCK_WAIT_TIMEOUT || ST_LOCK.equals(e.getSQLState());
    }
    if (recurse) {
        for (final Throwable thr : ExceptionUtils.getThrowables(t)) {
            if (isLockingException(thr, false)) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:18,代码来源:ExceptionHelper.java

示例3: indexOf

import org.apache.commons.lang.exception.ExceptionUtils; //导入方法依赖的package包/类
/**
 * <p>Worker method for the <code>indexOfType</code> methods.</p>
 *
 * @param throwable  the throwable to inspect, may be null
 * @param type  the type to search for, subclasses match, null returns -1
 * @param fromIndex  the (zero based) index of the starting position,
 *  negative treated as zero, larger than chain size returns -1
 * @param subclass if <code>true</code>, compares with {@link Class#isAssignableFrom(Class)}, otherwise compares
 * using references
 * @return index of the <code>type</code> within throwables nested withing the specified <code>throwable</code>
 */
private static int indexOf(Throwable throwable, Class type, int fromIndex, boolean subclass) {
    if (throwable == null || type == null) {
        return -1;
    }
    if (fromIndex < 0) {
        fromIndex = 0;
    }
    Throwable[] throwables = ExceptionUtils.getThrowables(throwable);
    if (fromIndex >= throwables.length) {
        return -1;
    }
    if (subclass) {
        for (int i = fromIndex; i < throwables.length; i++) {
            if (type.isAssignableFrom(throwables[i].getClass())) {
                return i;
            }
        }
    } else {
        for (int i = fromIndex; i < throwables.length; i++) {
            if (type.equals(throwables[i].getClass())) {
                return i;
            }
        }
    }
    return -1;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:38,代码来源:ExceptionUtils.java


注:本文中的org.apache.commons.lang.exception.ExceptionUtils.getThrowables方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。