Example usage for java.lang Exception getClass

List of usage examples for java.lang Exception getClass

Introduction

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

Prototype

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

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:org.easyj.rest.exceptions.UncaughtExceptionHandler.java

@Override
public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler,
        Exception ex) {/*from  ww w  .j  av  a2 s. c  o  m*/
    ModelAndView mav = new ModelAndView();

    String exception = "";
    Exception ex2 = ex;
    while (ex2 != null) {
        exception += "\n" + ex2.getClass().getSimpleName() + " - " + ex2.getMessage();
        ex2 = (Exception) ex2.getCause();
    }

    mav.setViewName(viewName);
    mav.addObject("status", UncaughtExceptionHandler.ERROR_STATUS);
    mav.addObject("exception", exception);
    response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);

    logger.error("Uncaught Exception Error", ex);

    return mav;
}

From source file:com.zuoxiaolong.niubi.job.service.impl.StandbyNodeServiceImpl.java

@Override
public List<StandbyNodeView> getAllNodes() {
    List<StandbyNodeData> standbyNodeDataList;
    List<StandbyNodeView> standbyNodeViewList = new ArrayList<>();
    try {//www .  j  ava  2s.  c om
        standbyNodeDataList = standbyApiFactory.nodeApi().getAllNodes();
    } catch (Exception e) {
        LoggerHelper.warn("select all standby nodes failed, has been ignored [" + e.getClass().getName() + ", "
                + e.getMessage() + "]");
        return standbyNodeViewList;
    }
    for (StandbyNodeData standbyNodeData : standbyNodeDataList) {
        StandbyNodeView standbyNodeView = new StandbyNodeView();
        standbyNodeView.setId(standbyNodeData.getId());
        if (standbyNodeData.getData() != null) {
            ReflectHelper.copyFieldValues(standbyNodeData.getData(), standbyNodeView);
        }
        standbyNodeViewList.add(standbyNodeView);
    }
    return standbyNodeViewList;
}

From source file:iddb.core.util.MailManager.java

public void sendMail(String subject, String template, String[] dest, Map<String, String> args)
        throws Exception {
    if (props == null)
        throw new Exception("Unable to access email subsystem.");
    try {//from w w  w . ja v  a2s.  c  o m
        Email email = new SimpleEmail();
        email.setSubject(subject);
        email.setMsg(TemplateManager.getTemplate(template, args));
        for (String adr : dest) {
            email.addTo(adr);
        }
        email.setCharset("ISO-8859-1");
        setEmailProps(email);
        email.send();
    } catch (Exception e) {
        log.error("{}: {}", e.getClass().getName(), e.getMessage());
        throw new Exception("We are unable to send your message right now.");
    }
}

From source file:net.nordist.lloydproof.CorrectionUploader.java

@Override
@SuppressWarnings("PMD.AvoidCatchingGenericException") // intentionally handling multiple
protected Void doInBackground(Void... params) {
    try {//from  www.  j  a  v a 2s. co  m
        JSONObject correctionsJSON = createCorrectionsJSON();
        JSONArray statusJSON = uploadCorrectionsJSON(correctionsJSON);
        deleteCorrectionsWithSuccessfulStatus(statusJSON);
    } catch (Exception e) {
        failureMessage = e.getClass().getSimpleName() + ": " + e.getMessage();
        Log.e(TAG, failureMessage);
        cancel(true);
    }
    return null;
}

From source file:iddb.core.util.MailManager.java

public void sendAdminMail(String subject, String message, String replyTo) throws Exception {
    if (props == null)
        throw new Exception("Unable to access email subsystem.");
    try {/*w ww .  j  a v  a  2 s  .c  om*/
        Email email = new SimpleEmail();
        email.setSubject(subject);
        email.setMsg(message);
        if (replyTo != null) {
            email.addReplyTo(replyTo);
        }
        for (String adr : props.getProperty("admin").split(";")) {
            email.addTo(adr);
        }
        setEmailProps(email);
        email.send();
    } catch (Exception e) {
        log.error("{}: {}", e.getClass().getName(), e.getMessage());
        throw new Exception("We are unable to send your message right now.");
    }
}

From source file:at.ait.dme.yuma.suite.apps.map.server.geo.MapMetadataServiceImpl.java

@Override
public MapMetadata getMetadata(String url) {
    try {/*from   ww w. ja va 2s.com*/
        GetMethod getMetadata = new GetMethod(url);
        int statusCode = new HttpClient().executeMethod(getMetadata);
        if (statusCode == HttpStatus.SC_OK) {
            return fromXML(getMetadata.getResponseBodyAsStream());
        }
    } catch (Exception e) {
        logger.info("No metadata found for " + url + " (" + e.getClass() + ")");
    }
    return null;
}

From source file:biz.netcentric.cq.tools.actool.validators.BeanValidatorsTest.java

private String getSimpleValidationException(final AceBean aceBean, final AceBeanValidator aceBeanValidator) {
    try {/*www  .  j a va 2  s .  c  o m*/
        aceBeanValidator.validate(aceBean, null);
    } catch (Exception e) {
        return e.getClass().getSimpleName();
    }
    return "";
}

From source file:biz.netcentric.cq.tools.actool.validators.BeanValidatorsTest.java

private String getSimpleValidationException(final AuthorizableConfigBean authorizableConfigBean,
        final AuthorizableValidator authorizableValidator) {
    try {//from  w w w . j  a v a  2 s .c om
        authorizableValidator.validate(authorizableConfigBean);
    } catch (Exception e) {
        return e.getClass().getSimpleName();
    }
    return "";
}

From source file:com.zuoxiaolong.niubi.job.service.impl.MasterSlaveNodeServiceImpl.java

@Override
public List<MasterNodeView> getAllNodes() {
    List<MasterSlaveNodeData> masterSlaveNodeDataList;
    List<MasterNodeView> masterNodeViewList = new ArrayList<>();
    try {//from   w  w  w .  j  ava  2  s  . c o m
        masterSlaveNodeDataList = masterSlaveApiFactory.nodeApi().getAllNodes();
    } catch (Exception e) {
        LoggerHelper.warn("select all standby nodes failed, has been ignored [" + e.getClass().getName() + ", "
                + e.getMessage() + "]");
        return masterNodeViewList;
    }
    if (masterSlaveNodeDataList == null) {
        return new ArrayList<>();
    }
    for (MasterSlaveNodeData masterSlaveNodeData : masterSlaveNodeDataList) {
        MasterNodeView masterNodeView = new MasterNodeView();
        masterNodeView.setId(masterSlaveNodeData.getId());
        if (masterSlaveNodeData.getData() != null) {
            ReflectHelper.copyFieldValues(masterSlaveNodeData.getData(), masterNodeView);
        }
        masterNodeViewList.add(masterNodeView);
    }
    return masterNodeViewList;
}

From source file:com.clustercontrol.performance.session.PerformanceControllerBean.java

/**
 * ??????//w  w  w.j  av  a2s.c  o m
 * 
 * @return ?ID??CollectorItemTreeItem?????HashMap
 */
public Map<String, CollectorItemTreeItem> getItemCodeMap() throws HinemosUnknown {
    m_log.debug("getItemCodeMap()");

    JpaTransactionManager jtm = null;
    Map<String, CollectorItemTreeItem> map = null;

    try {
        jtm = new JpaTransactionManager();
        jtm.begin();

        map = CollectorItemCodeTable.getItemCodeMap();
        jtm.commit();
    } catch (Exception e) {
        m_log.warn("getItemCodeMap() : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e);
        if (jtm != null)
            jtm.rollback();
        throw new HinemosUnknown(e.getMessage(), e);
    } finally {
        if (jtm != null)
            jtm.close();
    }
    return map;
}