Example usage for java.lang Exception getCause

List of usage examples for java.lang Exception getCause

Introduction

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

Prototype

public synchronized Throwable getCause() 

Source Link

Document

Returns the cause of this throwable or null if the cause is nonexistent or unknown.

Usage

From source file:net.orpiske.mdm.broker.main.actions.runner.BrokerRunner.java

public int run() {
    try {/*from  w  w  w  . j ava2s.  co  m*/
        initializeCamel();
        return 0;
    } catch (Exception e) {
        logger.error("Error: " + e.getMessage(), e);
        if (e.getCause() != null) {
            logger.error("Cause: " + e.getCause().getMessage(), e.getCause());
        }
        return -1;
    }
}

From source file:nz.co.senanque.vaadinsupport.viewmanager.TouchLoginForm.java

public void afterPropertiesSet() throws Exception {
    MessageSourceAccessor messageSourceAccessor = new MessageSourceAccessor(m_messageSource);
    usernameCaption = messageSourceAccessor.getMessage("username");
    passwordCaption = messageSourceAccessor.getMessage("password");
    submitCaption = messageSourceAccessor.getMessage("login.button");
    welcomeCaption = messageSourceAccessor.getMessage("welcome");
    final TextField userName = new TextField(usernameCaption);
    userName.setImmediate(true);/*from   www.  j a  v  a 2 s. co m*/
    addField("userName", userName);
    final PasswordField password = new PasswordField(passwordCaption);
    password.setImmediate(true);
    addField("password", password);
    Button submit = new Button(submitCaption);
    addField("submit", submit);
    submit.addListener(new ClickListener() {

        private static final long serialVersionUID = 5201900702970450254L;

        public void buttonClick(ClickEvent event) {
            Map<String, String> map = new HashMap<String, String>();
            map.put("user", String.valueOf(userName.getValue()));
            map.put("password", String.valueOf(password.getValue()));
            if (getLoginListener() != null) {
                try {
                    getLoginListener().onLogin(map);
                } catch (Exception e) {
                    Throwable cause = e.getCause();
                    if (cause == null || !(cause instanceof LoginException)) {
                        logger.error(e.getMessage(), e);
                    }
                    MessageSourceAccessor messageSourceAccessor = new MessageSourceAccessor(m_messageSource);
                    String message = messageSourceAccessor.getMessage("Bad.Login", "Bad Login");
                    TouchKitApplication.get().getMainWindow().showNotification(message,
                            Notification.TYPE_ERROR_MESSAGE);
                    return;
                }
            }
            TouchKitApplication.get().setUser(userName.getValue());
        }
    });
}

From source file:com.abc.turkey.web.unfreeze.UnfreezeController.java

@RequestMapping(value = "/cap_union_getsig_new")
public void getNewSig(HttpServletRequest request, HttpServletResponse response) {
    String url = captcha_prefix + "cap_union_getsig_new?" + request.getQueryString();
    HttpGet httpGet = new HttpGet(url);
    try {// w  ww.ja va 2  s  .c  om
        CloseableHttpResponse response2 = httpClient.execute(httpGet);
        response2.getEntity().writeTo(response.getOutputStream());
        response2.close();
    } catch (Exception e) {
        throw new ServiceException(e.getMessage(), e.getCause());
    }
}

From source file:com.abc.turkey.web.unfreeze.UnfreezeController.java

@RequestMapping(value = "/cap_union_getcapbysig_new")
public void getCaptchaImage(HttpServletRequest request, HttpServletResponse response) {
    String url = captcha_prefix + "cap_union_getcapbysig_new?" + request.getQueryString();
    HttpGet httpGet = new HttpGet(url);
    try {//from   www. j  a  v  a2s.  c o  m
        CloseableHttpResponse response2 = httpClient.execute(httpGet);
        response2.getEntity().writeTo(response.getOutputStream());
        response2.close();
    } catch (Exception e) {
        throw new ServiceException(e.getMessage(), e.getCause());
    }
}

From source file:com.abc.turkey.web.unfreeze.UnfreezeController.java

@RequestMapping(value = "/cap_union_verify_new")
public void capVerify(HttpServletRequest request, HttpServletResponse response) {
    String url = captcha_prefix + "cap_union_verify_new?" + request.getQueryString();
    HttpGet httpGet = new HttpGet(url);
    try {/*from  www  .  j  av a 2s  . co  m*/
        CloseableHttpResponse response2 = httpClient.execute(httpGet);
        response2.getEntity().writeTo(response.getOutputStream());
        response2.close();
    } catch (Exception e) {
        throw new ServiceException(e.getMessage(), e.getCause());
    }
}

From source file:info.magnolia.ui.framework.action.ActivationAction.java

@Override
protected void onError(Exception e) {
    String errorMessage = null;/* w  w  w. j  a v  a 2s .c o  m*/
    if (e.getCause() != null && e.getCause() instanceof ExchangeException) {
        errorMessage = e.getCause().getLocalizedMessage();
        errorMessage = StringUtils.substring(errorMessage,
                StringUtils.indexOf(errorMessage, "error detected:"));
    } else {
        errorMessage = getErrorMessage();
    }
    uiContext.openNotification(MessageStyleTypeEnum.ERROR, true, errorMessage);
}

From source file:tools.AssertingRestTemplate.java

@Override
protected <T> T doExecute(URI url, HttpMethod method, RequestCallback requestCallback,
        ResponseExtractor<T> responseExtractor) throws RestClientException {
    try {//from  w ww  .  ja  v a  2  s .  c  o m
        return super.doExecute(url, method, requestCallback, responseExtractor);
    } catch (Exception e) {
        log.error("Exception occurred while sending the message to uri [" + url + "]. Exception ["
                + e.getCause() + "]");
        throw new AssertionError(e);
    }
}

From source file:com.thoughtworks.go.util.command.ConsoleResult.java

public Exception smudgedException(Exception rawException) {
    try {//from ww w .j a  va 2 s  .c  o  m
        Throwable cause = rawException.getCause();
        if (cause != null) {
            smudgeException(cause);
        }
        smudgeException(rawException);
    } catch (Exception e) {
        ExceptionUtils.bomb(e);
    }
    return rawException;
}

From source file:de.u808.simpleinquest.indexer.impl.DefaultIndexer.java

public Document indexFile(File file) throws FileNotFoundException, IndexerException {
    Document document = null;/*from  w w  w . j  av a 2s  . c  o  m*/
    if (file.canRead()) {
        try {
            document = new Document();
            InputStream input = new FileInputStream(file);

            Metadata metadata = new Metadata();
            ContentHandler handler = new BodyContentHandler();
            new AutoDetectParser().parse(input, handler, metadata);

            document.add(new Field(Indexer.PATH_FIELD_NAME, file.getPath(), Field.Store.YES,
                    Field.Index.UN_TOKENIZED));
            document.add(new Field(Indexer.ID_FIELD_NAME, MD5Util.getInstance().getMD5Hex(file.getPath()),
                    Field.Store.YES, Field.Index.UN_TOKENIZED));

            document.add(new Field(Indexer.MODIFIED_FIELD_NAME,
                    DateTools.timeToString(file.lastModified(), DateTools.Resolution.MINUTE), Field.Store.YES,
                    Field.Index.UN_TOKENIZED));

            document.add(new Field(Indexer.CONTENT_FIELD_NAME, new StringReader(handler.toString())));
        } catch (Exception e) {
            if (e instanceof TikaException) {
                Throwable t = e.getCause();
                if (t != null && t.getMessage() != null) {
                    if (t.getMessage().startsWith("Error decrypting document")) {
                        log.debug("Cant index encrypted document.");
                        return document;
                    }
                }
            }
            throw new IndexerException(e.getMessage(), e);
        }
    } else {
        log.debug("Cant read file: " + file.getName());
    }
    return document;
}

From source file:com.vmware.bdd.service.impl.SetLocalRepoService.java

@Override
public boolean setLocalRepoForNode(String clusterName, NodeEntity node, String repoId, String localRepoURL)
        throws Exception {
    AuAssert.check(clusterName != null && node != null);

    SetLocalRepoSP setLocalRepoSP = new SetLocalRepoSP(node, repoId, localRepoURL);
    String vmNameWithIP = node.getVmNameWithIP();
    try {/*from  w  w  w  . j  a  va2 s . co  m*/
        if (setLocalRepoSP.setupNodeLocalRepo()) {
            updateNodeData(node, true, null, null);
            logger.info("Set local repo for " + vmNameWithIP + " succeed.");
            return true;
        }
        //we fail by throwing exceptions
        logger.error("Should not reach here");
        return false;
    } catch (Exception e) {
        String errMsg = (e.getCause() == null ? e.getMessage() : e.getCause().getMessage());
        updateNodeData(node, false, errMsg, CommonUtil.getCurrentTimestamp());
        logger.error("Set local repo for " + vmNameWithIP + " failed. ", e);
        return false;
    }
}