Example usage for java.lang Throwable getMessage

List of usage examples for java.lang Throwable getMessage

Introduction

In this page you can find the example usage for java.lang Throwable getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.aptana.core.epl.downloader.RepositoryStatusHelper.java

private static void deeplyPrint(IStatus status, PrintStream strm, boolean stackTrace, int level) {
    appendLevelString(strm, level);/*from  w w  w  .j  av a2 s. c o  m*/
    String msg = status.getMessage();
    strm.println(msg);
    Throwable cause = status.getException();
    if (cause != null) {
        strm.print("Caused by: "); //$NON-NLS-1$
        if (stackTrace || !(msg.equals(cause.getMessage()) || msg.equals(cause.toString())))
            deeplyPrint(cause, strm, stackTrace, level);
    }

    if (status.isMultiStatus()) {
        IStatus[] children = status.getChildren();
        for (int i = 0; i < children.length; i++)
            deeplyPrint(children[i], strm, stackTrace, level + 1);
    }
}

From source file:com.vmware.identity.idm.server.clientcert.IdmClientCertificateValidator.java

/**
 * Parse DER-encoded bytes to locate a String object
 *
 * @param alterNameValue DER encoded data
 * @return First string found/*from w  ww.  j  a  va  2 s  .co  m*/
 * @throws Throwable
 */
private static String parseDERString(byte[] alterNameValue) throws Throwable {
    try {
        ASN1StreamParser p = new ASN1StreamParser(alterNameValue);
        ASN1Encodable d = p.readObject();
        ASN1Primitive der = d.toASN1Primitive();

        return getStringFromObject(der);
    } catch (Throwable e) {
        // Exception indicates parsing failed, skip this
        // value (most likely not UPN format)
        logger.error("Unable to extract User Principal Name: " + e.getMessage());
        throw e;
    }
}

From source file:adalid.commons.util.ThrowableUtils.java

public static String getString(Throwable throwable) {
    if (throwable == null) {
        return Throwable.class.getName();
    }/* w  ww . j av a2s  .c  o m*/
    String string;
    Throwable cause = throwable.getCause();
    if (cause != null) {
        return getString(cause);
    }
    string = throwable.getLocalizedMessage();
    if (StringUtils.isNotBlank(string)) {
        return getString(string);
    }
    string = throwable.getMessage();
    if (StringUtils.isNotBlank(string)) {
        return getString(string);
    }
    string = throwable.toString();
    if (StringUtils.isNotBlank(string)) {
        return getString(string);
    }
    return Throwable.class.getSimpleName();
}

From source file:com.momock.util.Logger.java

public static void error(Throwable e) {
    if (!enabled || logLevel > LEVEL_ERROR)
        return;/*ww  w  . ja v a  2 s .c om*/
    String msg = e.getMessage() + " : " + getStackTrace(e);
    Throwable t = new Throwable();
    StackTraceElement trace = t.getStackTrace()[1];
    android.util.Log.e(logName, msg + " @ " + getSourceInfo(trace));
    checkLogFile();
    logStream.println(getLog("ERROR", msg));
    logStream.flush();
    event.fireEvent(null, new LogEventArgs(null, e));
}

From source file:com.aptana.core.epl.downloader.RepositoryStatusHelper.java

public static IStatus createExceptionStatus(Throwable cause) {
    return (cause instanceof CoreException) ? ((CoreException) cause).getStatus()
            : new Status(IStatus.ERROR, CoreEPLPlugin.PLUGIN_ID, IStatus.OK, cause.getMessage(), cause);
}

From source file:net.firejack.platform.web.security.x509.KeyUtils.java

public static KeyPair generate(File keystore) {
    if (keystore == null) {
        throw new IllegalArgumentException("Key Store file should not be null.");
    }//w ww .j a  v  a  2s .com

    try {
        KeyStore ks = KeyStore.getInstance("JKS", "SUN");
        if (keystore.exists()) {
            FileInputStream stream = new FileInputStream(keystore);
            ks.load(stream, SECRET);
            IOUtils.closeQuietly(stream);
        } else {
            ks.load(null, SECRET);
        }

        if (ks.containsAlias(ALIAS)) {
            PrivateKey privateKey = (PrivateKey) ks.getKey(ALIAS, SECRET);
            PublicKey publicKey = ks.getCertificate(ALIAS).getPublicKey();
            return new KeyPair(publicKey, privateKey);
        } else {
            KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA");
            generator.initialize(KEYSIZE, new SecureRandom());
            return generator.generateKeyPair();
        }
    } catch (Throwable th) {
        logger.error("Failed to initialize key store");
        throw new OpenFlameRuntimeException(th.getMessage(), th);
    }
}

From source file:net.firejack.platform.web.security.x509.KeyUtils.java

public static void add(File keystore, KeyPair pair, String domain) {
    if (keystore == null) {
        throw new IllegalArgumentException("Key Store file should not be null.");
    }/*ww w . j a v a 2s  .  c om*/

    try {
        KeyStore ks = KeyStore.getInstance("JKS", "SUN");
        if (keystore.exists()) {
            FileInputStream stream = new FileInputStream(keystore);
            ks.load(stream, SECRET);
            IOUtils.closeQuietly(stream);
        } else {
            ks.load(null, SECRET);
        }

        if (!ks.containsAlias(ALIAS)) {
            X509Certificate certificate = generateCertificate(domain, 1, pair);

            ks.setKeyEntry(ALIAS, pair.getPrivate(), SECRET, new Certificate[] { certificate });

            FileOutputStream stream = new FileOutputStream(keystore);
            ks.store(stream, SECRET);
            IOUtils.closeQuietly(stream);
        }
    } catch (Throwable th) {
        logger.error("Failed to initialize key store");
        throw new OpenFlameRuntimeException(th.getMessage(), th);
    }
}

From source file:mp.platform.cyclone.webservices.utils.WebServiceHelper.java

/**
 * Returns a SOAP fault//from  ww  w. j a  v  a  2  s  .  c o  m
 */
private static SoapFault fault(final String code, final Throwable th) throws SoapFault {
    SoapFault sf = new SoapFault("Server error: " + code, th, faultCode(code));
    if (th != null) {
        org.w3c.dom.Element el = sf.getOrCreateDetail();
        el.setTextContent(th.getMessage());
        sf.setDetail(el);
    }
    return sf;
}

From source file:net.firejack.platform.web.security.x509.KeyUtils.java

public static KeyPair load(File keyStoreFile) {
    if (keyStoreFile != null) {
        try {//from   w w w  .  jav  a 2  s .  c om
            KeyStore ks = KeyStore.getInstance("JKS", "SUN");
            if (keyStoreFile.exists()) {
                FileInputStream stream = new FileInputStream(keyStoreFile);
                ks.load(stream, SECRET);
                IOUtils.closeQuietly(stream);

                PrivateKey privateKey = (PrivateKey) ks.getKey(ALIAS, SECRET);
                if (privateKey == null)
                    return null;
                PublicKey publicKey = ks.getCertificate(ALIAS).getPublicKey();
                return new KeyPair(publicKey, privateKey);
            }
        } catch (Throwable th) {
            logger.error("Failed to initialize key store");
            throw new OpenFlameRuntimeException(th.getMessage(), th);
        }
    } else {
        throw new IllegalArgumentException("Key Store file should not be null.");
    }
    return null;
}

From source file:com.microsoft.alm.plugin.idea.tfvc.core.TFSVcs.java

public static VcsException convertToVcsException(final Throwable throwable) {
    if (throwable instanceof VcsException) {
        return (VcsException) throwable;
    }//w w  w  .j a v  a2  s  .c o m

    final VcsException exception = new VcsException(throwable.getMessage(), throwable);
    if (throwable instanceof SyncException) {
        exception.setIsWarning(((SyncException) throwable).isWarning());
    }

    return exception;
}