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:org.apache.nutch.webui.service.impl.NutchServiceImpl.java

@Override
public ConnectionStatus getConnectionStatus(Long instanceId) {
    NutchInstance instance = instanceService.getInstance(instanceId);
    try {//from w w  w .jav  a2 s.  c om
        NutchStatus nutchStatus = nutchClientFactory.getClient(instance).getNutchStatus();
        if (nutchStatus.getStartDate() != null) {
            return ConnectionStatus.CONNECTED;
        }
    } catch (Exception e) {
        if (e.getCause() instanceof ConnectException) {
            return ConnectionStatus.DISCONNECTED;
        }

        logger.error("Cannot connect to nutch server!", e);
    }
    return null;
}

From source file:co.sip.dmesmobile.bs.ScUsersDao.java

public ScUsers findByLogin(String login) throws Exception {
    entityManager = Factory.getEntityManagerFactory().createEntityManager();
    ScUsers result = null;// w ww . ja v a  2 s  . c o  m
    try {
        Query query = entityManager.createNamedQuery("ScUsers.findByLogin");
        query.setParameter("login", login);
        result = (ScUsers) query.getSingleResult();
    } catch (Exception e) {
        log.error("Error intentando consultar el usuario", e.getCause());
    }
    return result;
}

From source file:com.netflix.spinnaker.fiat.providers.DefaultAccountProvider.java

@Override
protected Set<Account> loadAll() throws ProviderException {
    try {// w w  w .j a va  2  s  .c o  m
        return new HashSet<>(clouddriverService.getAccounts());
    } catch (Exception e) {
        throw new ProviderException(this.getClass(), e.getCause());
    }
}

From source file:Verifier.java

/**
 * Convenience method to launch verification
 * @param ev - Expected Value//w w  w.j  av a  2s  .c o  m
 * @param av - Actual Value
 * @param md - Comparison Mode
 * @param opt - Verification option (applies to string)
 * @param cls - object class name ("Integer", "Date", "Amount"...)
 * @param stripWhiteSpace - if true, strip actual value and expected values of all white space characters before comparison / verification.
 * @return    - Verifier instance with verification result - us isPass() to determine success or failure
 */
public static Verifier verify(String ev, String av, String md, String opt, String cls,
        boolean stripWhiteSpace) {
    Verifier v = new Verifier(ev, av, md, opt, cls, stripWhiteSpace);
    try {
        v.verify();
    } catch (Exception e) {
        v.addError(trim(v.getErrors() + " " + e.getCause().toString()));
    } finally {
        return v;
    }
}

From source file:com.mysoft.b2b.event.util.MysoftDataSource.java

/**
 * ???????? /*from ww w .  ja v a2 s.  c om*/
 * ????
 */
@Override
public void afterPropertiesSet() throws Exception {
    try {
        super.getConnection();
    } catch (Exception e) {
        logger.error("??" + e.getMessage(), e.getCause());
        System.exit(1);
    }
}

From source file:org.openwms.common.HttpCommonGateway.java

private int translate(Exception ex) {
    if (ex.getCause() instanceof FeignException) {
        return ((FeignException) ex.getCause()).status();
    }/* w w w. ja  va 2 s  .c om*/
    LOGGER.error(ex.getMessage(), ex);
    throw new ServiceLayerException(ex.getMessage());
}

From source file:com.netflix.spinnaker.fiat.providers.DefaultApplicationProvider.java

@Override
protected Set<Application> loadAll() throws ProviderException {
    try {/*from  ww  w.  j a  v  a  2 s .com*/
        Map<String, Application> appByName = front50Service.getAllApplicationPermissions().stream()
                .collect(Collectors.toMap(Application::getName, Function.identity()));

        clouddriverService.getApplications().stream().filter(app -> !appByName.containsKey(app.getName()))
                .forEach(app -> appByName.put(app.getName(), app));

        return new HashSet<>(appByName.values());
    } catch (Exception e) {
        throw new ProviderException(this.getClass(), e.getCause());
    }
}

From source file:com.netflix.spinnaker.fiat.providers.DefaultServiceAccountProvider.java

@Override
protected Set<ServiceAccount> loadAll() throws ProviderException {
    try {//  w  w w .  jav a  2 s .  c o  m
        return new HashSet<>(front50Service.getAllServiceAccounts());
    } catch (Exception e) {
        throw new ProviderException(this.getClass(), e.getCause());
    }
}

From source file:com.alliander.osgp.shared.usermanagement.ApiResponse.java

public void setApiResponseToError(final Exception e) {
    this.setFeedbackMessage(StringUtils.EMPTY);
    if (e.getCause() != null) {
        this.setErrorMessage(e.getMessage() + " | " + e.getCause());
    } else {//ww  w .j a v a2 s  . co m
        this.setErrorMessage(e.getMessage());
    }
}

From source file:com.nts.alphamale.shell.AdbShellExecutor.java

/**
 * @param cmd adb /*from w  w w.  j  a va 2 s  .co  m*/
 * @param synch   ? ? true: synchronous, false: asynchronous
 * @param  (ms)
 * @return Executor Standard Output? Map
 */
public int execute(CommandLine cmd, int exitValue) {
    int rtnValue = -1;
    DefaultExecutor executor = new DefaultExecutor();
    executor.setExitValue(exitValue);
    try {
        rtnValue = executor.execute(cmd);
    } catch (Exception e) {
        log.error(e.getCause() + ":" + e.getMessage() + "[" + cmd + "]");
    }
    return rtnValue;
}