Example usage for java.lang Throwable getClass

List of usage examples for java.lang Throwable getClass

Introduction

In this page you can find the example usage for java.lang Throwable getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:com.joyent.manta.http.InstrumentedMantaHttpRequestExecutor.java

/**
 * Get a reference to (or create) a {@link Meter} based on the supplied exception.
 *
 * @param e exception type to be tracked
 * @return a meter within the registry/*from   w  ww. j av a 2  s  . c  o  m*/
 */
private Meter meter(final Exception e) {
    final Throwable rootEx = ObjectUtils.firstNonNull(ExceptionUtils.getRootCause(e), e);

    return registry.meter("exceptions-" + rootEx.getClass().getSimpleName());
}

From source file:uk.codingbadgers.SurvivalPlus.error.ReportExceptionRunnable.java

private String getException(Throwable cause) {
    while (cause.getCause() != null) {
        cause = cause.getCause();//from   w  w w  .  ja  v a  2s .  c  o  m
    }

    return cause.getClass().getName();
}

From source file:com.ejisto.modules.controller.wizard.installer.workers.LoadClassAction.java

private ErrorDescriptor buildErrorDescriptor(Throwable e) {
    Class<?> c = e.getClass();
    boolean classIssue = NotFoundException.class.isAssignableFrom(c) || LinkageError.class.isAssignableFrom(c);
    return new ErrorDescriptor(e, classIssue ? WARN : ERROR);
}

From source file:io.brooklyn.ambari.service.AbstractExtraServiceTest.java

@Test
public void getComponentMappingsThrowExIfNoHost() {
    try {/* w  w  w. j a  va 2s . c  o  m*/
        app.createAndManageChild(createDummyExtraServiceSpec(null, null, ImmutableList.of("MY_COMPONENT")))
                .getComponentMappings();
        fail();
    } catch (Throwable throwable) {
        Throwable rootCause = ExceptionUtils.getRootCause(throwable);

        assertEquals(NullPointerException.class, rootCause.getClass());
        assertEquals("Default host is required", rootCause.getMessage());
    }
}

From source file:net.community.chest.gitcloud.facade.AbstractEnvironmentInitializer.java

@Override
public void contextInitialized(ServletContextEvent sce) {
    Log curLogger = logger;//from  ww w  . j av  a 2 s . c om
    try {
        ServletContext context = sce.getServletContext();
        logger = ServletUtils.wrapServletContext(context, Level.CONFIG);
        contextInitialized(context);
        logger.info("contextInitialized(" + context.getContextPath() + ")");
    } catch (Throwable t) {
        logger.error("Failed (" + t.getClass().getSimpleName() + ") to initialize: " + t.getMessage(), t);
        throw ExtendedExceptionUtils.toRuntimeException(t, true);
    } finally {
        logger = curLogger;
    }
}

From source file:net.community.chest.gitcloud.facade.AbstractEnvironmentInitializer.java

@Override
public void contextDestroyed(ServletContextEvent sce) {
    Log curLogger = logger;/*  w w w . j a v  a2  s.  co  m*/
    try {
        ServletContext context = sce.getServletContext();
        logger = ServletUtils.wrapServletContext(context, Level.CONFIG);
        contextDestroyed(context);
        logger.info("contextDestroyed(" + context.getContextPath() + ")");
    } catch (Throwable t) {
        logger.error("Failed (" + t.getClass().getSimpleName() + ") to destroy: " + t.getMessage(), t);
        throw ExtendedExceptionUtils.toRuntimeException(t, true);
    } finally {
        logger = curLogger;
    }
}

From source file:com.ebay.pulsar.sessionizer.impl.SessionizerErrorManager.java

private void incCounter(Throwable ex, ErrorType type) {
    errorCount.incrementAndGet();/*from w  w  w . j  a va2 s.c o  m*/

    long v = incCounter(ex.getClass().getName(), type);
    if (v % 1000000 == 1) {
        //print exception for first time.
        LOGGER.error("Exception count=" + v, ex);
    }
}

From source file:business.CustomResponseEntityExceptionHandler.java

@Override
protected ResponseEntity<Object> handleHttpMessageNotReadable(HttpMessageNotReadableException ex,
        HttpHeaders headers, HttpStatus status, WebRequest request) {
    Throwable mostSpecificCause = ex.getMostSpecificCause();
    ErrorMessage errorMessage;/*w ww. ja v a 2 s .  c  o  m*/
    if (mostSpecificCause != null) {
        String exceptionName = mostSpecificCause.getClass().getName();
        String message = mostSpecificCause.getMessage();
        errorMessage = new ErrorMessage(exceptionName, message);
    } else {
        errorMessage = new ErrorMessage(ex.getMessage());
    }
    return new ResponseEntity<Object>(errorMessage, headers, status);
}

From source file:com.qpark.eip.core.spring.statistics.FlowExecutionLog.java

/**
 * Aspect around the execution of the invokeFlow method of all
 * {@link com.qpark.eip.inf.Flow} implementations.
 *
 * @param joinPoint/*from   ww  w  .  ja  v  a  2 s .  co  m*/
 *            The {@link ProceedingJoinPoint}.
 * @return the result of the flow.
 * @throws Throwable
 */
@Around(value = "execution(* com.qpark.eip.inf.Flow+.invokeFlow(..)) || execution(public * com.qpark.eip.inf.FlowGateway+.*(..))")
public Object invokeFlowAspect(final ProceedingJoinPoint joinPoint) throws Throwable {
    long start = System.currentTimeMillis();
    String interfaceName = this.getInterfaceName(joinPoint);
    String methodName = this.getMethodName(joinPoint);
    String userName = "";
    if (joinPoint.getArgs().length > 0 && joinPoint.getArgs()[0] != null) {
        userName = this.messageContentProvider.getUserName(joinPoint.getArgs()[0]);
    }
    this.logger.debug("+{}.{}({})", interfaceName, methodName, userName);
    Object result = null;
    try {
        result = joinPoint.proceed();
    } catch (Throwable t) {
        this.logger.debug(" {}.{}({}) failed with {}: {}", interfaceName, methodName, userName,
                t.getClass().getSimpleName(), t.getMessage());
        throw t;
    } finally {
        this.logger.debug("-{}.{}({}) {}", interfaceName, methodName, userName,
                DateUtil.getDuration(start, System.currentTimeMillis()));
    }
    return result;
}

From source file:com.vladmihalcea.concurrent.aop.OptimisticConcurrencyControlAspect.java

private boolean isRetryThrowable(Throwable throwable, Class<? extends Throwable>[] retryOn) {
    Throwable[] causes = ExceptionUtils.getThrowables(throwable);
    for (Throwable cause : causes) {
        for (Class<? extends Throwable> retryThrowable : retryOn) {
            if (retryThrowable.isAssignableFrom(cause.getClass())) {
                return true;
            }//from   w w w . j  a  va2 s.  c  o m
        }
    }
    return false;
}