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.samples.platform.util.ServiceExecutionLogAspect.java

/**
 * Aspect around the execution of the services.
 *
 * @param joinPoint/*from www  .ja v  a2 s. c  o  m*/
 *            The {@link ProceedingJoinPoint}.
 * @return the result of the service execution.
 * @throws Throwable
 */
@Around(value = "execution(* com.qpark.eip.service.*.*(..)) || execution(* com.samples.platform.service.*.*(..)) ")
public Object invokeAspect(final ProceedingJoinPoint joinPoint) throws Throwable {
    long start = System.currentTimeMillis();
    String signatureName = this.getSignatureName(joinPoint);
    this.logger.debug("+{}", signatureName);
    Object result = null;
    try {
        result = joinPoint.proceed();
    } catch (Throwable t) {
        this.logger.debug(" {} failed with {}: {}", signatureName, t.getClass().getSimpleName(),
                t.getMessage());
        throw t;
    } finally {
        this.logger.debug("-{} {}", signatureName, getDuration(System.currentTimeMillis() - start));
    }
    return result;
}

From source file:org.trustedanalytics.examples.hbase.api.ExceptionHandlerAdvice.java

private HttpStatus resolveAnnotatedResponseStatus(Throwable ex) {
    ResponseStatus responseStatus = findMergedAnnotation(ex.getClass(), ResponseStatus.class);
    if (responseStatus != null) {
        return responseStatus.code();
    } else if (ex.getCause() instanceof Exception) {
        return resolveAnnotatedResponseStatus(ex.getCause());
    }// w w w .  j  a v  a2s.  co  m
    return null;
}

From source file:ca.bluemeta.util.ObjectUtils.java

/**
 * Check whether the given exception is compatible with the exceptions declared in a throws clause.
 *
 * @param ex the exception to checked//w  w  w  .  jav  a  2  s  .co  m
 * @param declaredExceptions the exceptions declared in the throws clause
 * @return whether the given exception is compatible
 */
public static boolean isCompatibleWithThrowsClause(Throwable ex, Class[] declaredExceptions) {
    if (!isCheckedException(ex)) {
        return true;
    }
    if (declaredExceptions != null) {
        int i = 0;
        while (i < declaredExceptions.length) {
            if (declaredExceptions[i].isAssignableFrom(ex.getClass())) {
                return true;
            }
            i++;
        }
    }
    return false;
}

From source file:org.nuxeo.ecm.automation.client.cache.CachedHttpConnector.java

@Override
protected boolean isNetworkError(Throwable t) {
    String className = t.getClass().getName();

    if (className.startsWith("java.net.")) {
        return true;
    }//from  w w  w .j ava  2 s  .c om
    if (className.startsWith("org.apache.http.conn.")) {
        return true;
    }
    return false;
}

From source file:com.jayway.airportweather.AirportWeatherTest.java

private void expectRollback(String message) {
    ProducerTemplate template = context.createProducerTemplate();
    String body = "EWR";
    try {/*from   w w  w .  ja  va 2 s  . c o  m*/
        template.requestBody(AirportWeather.GET_MAXIMUM_TEMPERATUR_AT_AIRPORT, body);
        fail("Expected exception");
    } catch (CamelExecutionException e) {
        Throwable cause = e.getCause();
        assertEquals(RollbackExchangeException.class, cause.getClass());
        assertTrue(cause.getMessage().contains(message));
    }
}

From source file:controllers.AbstractController.java

@ExceptionHandler(Throwable.class)
public ModelAndView panic(Throwable oops) {
    ModelAndView result;/* w  ww  . j av a2  s  . co m*/

    result = new ModelAndView("misc/panic");
    result.addObject("name", ClassUtils.getShortName(oops.getClass()));
    result.addObject("exception", oops.getMessage());
    result.addObject("stackTrace", ExceptionUtils.getStackTrace(oops));

    return result;
}

From source file:com.googlecode.jsonrpc4j.DefaultErrorResolver.java

/**
 * {@inheritDoc}/*from w  ww  . j  ava 2s.c o  m*/
 */
public JsonError resolveError(Throwable t, Method method, List<JsonNode> arguments) {
    return new JsonError(0, t.getMessage(), new ErrorData(t.getClass().getName(), t.getMessage()));
}

From source file:net.sourceforge.subsonic.filter.RESTFilter.java

private String getErrorMessage(Throwable x) {
    if (x.getMessage() != null) {
        return x.getMessage();
    }//from   ww  w .  ja  va 2  s . c o  m
    return x.getClass().getSimpleName();
}

From source file:org.biokoframework.http.exception.impl.ExceptionResponseBuilderImpl.java

private String descriptionOf(Throwable throwable) {
    StringBuilder message = new StringBuilder().append(throwable.getClass().getName());
    if (!StringUtils.isEmpty(throwable.getMessage())) {
        message.append(" with message '").append(throwable.getMessage()).append("'");
    }//w w  w  .j a  v  a2 s  . c om
    message.append(" [").append(throwable.getStackTrace()[0]).append("]");
    if (throwable.getCause() != null) {
        message.append(" Caused by " + descriptionOf(throwable.getCause()));
    }
    return message.toString();
}

From source file:zipkin.server.ZipkinHttpCollector.java

ListenableFuture<ResponseEntity<?>> validateAndStoreSpans(String encoding, Codec codec, byte[] body) {
    SettableListenableFuture<ResponseEntity<?>> result = new SettableListenableFuture<>();
    metrics.incrementMessages();/*from www.  j  a  va 2 s.  c  om*/
    if (encoding != null && encoding.contains("gzip")) {
        try {
            body = gunzip(body);
        } catch (IOException e) {
            metrics.incrementMessagesDropped();
            result.set(ResponseEntity.badRequest().body("Cannot gunzip spans: " + e.getMessage() + "\n"));
        }
    }
    collector.acceptSpans(body, codec, new Callback<Void>() {
        @Override
        public void onSuccess(@Nullable Void value) {
            result.set(SUCCESS);
        }

        @Override
        public void onError(Throwable t) {
            String message = t.getMessage() == null ? t.getClass().getSimpleName() : t.getMessage();
            result.set(t.getMessage() == null || message.startsWith("Cannot store")
                    ? ResponseEntity.status(500).body(message + "\n")
                    : ResponseEntity.status(400).body(message + "\n"));
        }
    });
    return result;
}