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.alliander.osgp.acceptancetests.devicemanagement.SetOwnerSteps.java

@DomainStep("the set owner request is received on OSGP")
public void whenTheSetOwnerRequestIsReceivedOnOSGP()
        throws UnknownEntityException, ValidationException, NotAuthorizedException {
    LOGGER.info("WHEN: \"the set owner request is received on OSGP\".");

    try {//from w  w  w.  j a  va  2  s .  co  m
        this.response = this.deviceManagementEndpoint.setOwner(ORGANISATION_ID, this.request);
    } catch (final Throwable t) {
        LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage());
    }
}

From source file:com.opengamma.engine.view.calcnode.MutableExecutionLog.java

public void setException(Throwable exception) {
    _exceptionClass = exception.getClass().getName();
    _exceptionMessage = exception.getMessage();
    final StringBuffer buffer = new StringBuffer();
    for (StackTraceElement element : exception.getStackTrace()) {
        buffer.append(element.toString() + "\n");
    }/*from  www .  j a v a  2  s  .  co  m*/
    _exceptionStackTrace = buffer.toString();
}

From source file:com.fengduo.spark.commons.component.ComponentController.java

@ExceptionHandler(Throwable.class)
public ModelAndView handleIOException(Throwable e) throws Throwable {

    if (AnnotationUtils.findAnnotation(e.getClass(), ResponseStatus.class) != null) {
        throw e;//from  w  w  w  .  j  a  v a2s  .  co m
    }

    if (request == null && response == null) {
        throw e;
    }

    if (request == null && response != null) {
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=UTF-8");
        OutputStream out = response.getOutputStream();
        PrintWriter pw = new PrintWriter(new OutputStreamWriter(out, "utf-8"));
        pw.println("{\"code\":1,\"msg\":\",?!\",\"data\":\"\"}");
        pw.flush();
        pw.close();
    }

    ModelAndView mav = new ModelAndView();
    // if (InvokeTypeTools.isAjax(request)) {
    // return createJsonMav("server exceptin or error", ResultCode.ERROR, e.getMessage());
    // }

    mav.addObject("exception", e.getCause() == null ? StringUtils.EMPTY : e.getCause().toString());
    mav.addObject("msg", StringUtils.isEmpty(e.getMessage()) ? e.toString() : e.getMessage());
    mav.addObject("stackTrace", e.getStackTrace().toString());
    if (request.getRequestURI() != null) {
        mav.addObject("url", request.getRequestURI().toString());
    }
    mav.setViewName("error");
    return mav;
}

From source file:com.haulmont.cuba.core.global.RemoteException.java

private boolean isSuitable(Throwable throwable) {
    return (throwable.getClass().getName().startsWith("java.")
            || throwable.getClass().isAnnotationPresent(SupportedByClient.class));
}

From source file:com.zb.app.common.component.ComponentController.java

@ExceptionHandler(Throwable.class)
public ModelAndView handleIOException(Throwable e) throws Throwable {

    if (AnnotationUtils.findAnnotation(e.getClass(), ResponseStatus.class) != null) {
        throw e;//from  w w w . ja v  a 2 s . c  o  m
    }

    if (request == null && response == null) {
        throw e;
    }

    if (request == null && response != null) {
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=UTF-8");
        OutputStream out = response.getOutputStream();
        PrintWriter pw = new PrintWriter(new OutputStreamWriter(out, "utf-8"));
        pw.println("{\"code\":1,\"msg\":\",?!\",\"data\":\"\"}");
        pw.flush();
        pw.close();
    }

    ModelAndView mav = new ModelAndView();
    if (InvokeTypeTools.isAjax(request)) {
        return createJsonMav("server exceptin or error", ResultCode.ERROR, e.getMessage());
    }

    mav.addObject("exception", e.getCause() == null ? StringUtils.EMPTY : e.getCause().toString());
    mav.addObject("msg", StringUtils.isEmpty(e.getMessage()) ? e.toString() : e.getMessage());
    mav.addObject("stackTrace", e.getStackTrace().toString());
    if (request.getRequestURI() != null) {
        mav.addObject("url", request.getRequestURI().toString());
    }
    mav.setViewName("error");
    return mav;
}

From source file:com.bitranger.parknshop.util.ObjUtils.java

/**
 * Check whether the given exception is compatible with the exceptions
 * declared in a throws clause.//from  w w  w . j a v a 2  s.c o  m
 * @param ex the exception to checked
 * @param declaredExceptions the exceptions declared in the throws clause
 * @return whether the given exception is compatible
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
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:com.github.rozidan.springboot.logger.LoggerMsgFormatter.java

private String errClass(Throwable err) {
    return err.getClass().getName();
}

From source file:com.vmware.appfactory.common.AfFailure.java

/**
 * Create a new instance from the given error.
 * The summary is set to the error message; the detail remains null.
 *
 * @param error/*from w  ww.ja v  a2 s . co m*/
 */
public AfFailure(Throwable error) {
    _summary = error.getMessage();
    if (StringUtils.isBlank(_summary)) {
        _summary = error.getClass().getName();
    }
    _details = null;
}

From source file:com.fengduo.bee.commons.component.ComponentController.java

@ExceptionHandler(Throwable.class)
public ModelAndView handleIOException(Throwable e) throws Throwable {

    if (AnnotationUtils.findAnnotation(e.getClass(), ResponseStatus.class) != null) {
        throw e;/* w w w . j  a v  a2 s .com*/
    }

    if (request == null && response == null) {
        throw e;
    }

    if (request == null && response != null) {
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=UTF-8");
        OutputStream out = response.getOutputStream();
        PrintWriter pw = new PrintWriter(new OutputStreamWriter(out, "utf-8"));
        pw.println("{\"code\":1,\"msg\":\",?!\",\"data\":\"\"}");
        pw.flush();
        pw.close();
    }

    ModelAndView mav = new ModelAndView();
    // if (InvokeTypeTools.isAjax(request)) {
    // return createJsonMav("server exceptin or error", ResultCode.ERROR,
    // e.getMessage());
    // }

    mav.addObject("exception", e.getCause() == null ? StringUtils.EMPTY : e.getCause().toString());
    mav.addObject("msg", StringUtils.isEmpty(e.getMessage()) ? e.toString() : e.getMessage());
    mav.addObject("stackTrace", e.getStackTrace().toString());
    if (request.getRequestURI() != null) {
        mav.addObject("url", request.getRequestURI().toString());
    }
    mav.setViewName("error");
    return mav;
}

From source file:com.opengamma.engine.calcnode.MutableExecutionLog.java

public void setException(Throwable exception) {
    _exceptionClass = exception.getClass().getName();
    _exceptionMessage = exception.getMessage();
    final StringBuilder buffer = new StringBuilder();
    for (StackTraceElement element : exception.getStackTrace()) {
        buffer.append(element.toString()).append("\n");
    }//from ww  w.j  av a 2s .  c  o  m
    _exceptionStackTrace = buffer.toString();
    _logLevels.add(LogLevel.WARN);
}