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:net.rim.ejde.internal.util.ComponentPackUtils.java

/**
 * Gets the component pack paths based on the CP extension point
 *
 * @return the component pack paths//from ww w.  j  av a2s  .  c  o m
 */
public static Map<String, JDEInfo> getComponentPackPaths() {
    ComponentPackUtils.log.debug("Starting Search for CPs"); //$NON-NLS-1$
    IExtension[] extensions;
    final IExtensionRegistry registry = RegistryFactory.getRegistry();
    final IExtensionPoint point = registry.getExtensionPoint(IConstants.CP_EXTENSION_POINT_ID);
    final TreeMap<String, JDEInfo> packs = new TreeMap<String, JDEInfo>(new ComponentPackComparator());

    if ((null == point) || !point.isValid()) {
        ComponentPackUtils.log.debug("Extention Point Null or Invalid"); //$NON-NLS-1$
        return packs;
    }
    extensions = point.getExtensions();

    if ((null == extensions) || (0 == extensions.length)) {
        ComponentPackUtils.log.debug("Extentions Null or Non-Existant"); //$NON-NLS-1$
        return packs;
    }

    Bundle bundle;
    URL url;

    String name, version, path;
    File file;

    for (final IExtension extension : extensions) {
        try {
            bundle = Platform.getBundle(extension.getNamespaceIdentifier());
            final int bundleState = bundle.getState();

            if ((bundleState != Bundle.UNINSTALLED) && (bundleState != Bundle.STOPPING)) {

                url = FileLocator.resolve(FileLocator.find(bundle, Path.ROOT, null));

                name = bundle.getHeaders().get(Constants.BUNDLE_NAME);
                version = bundle.getHeaders().get(Constants.BUNDLE_VERSION);

                if (StringUtils.isBlank(name) || StringUtils.isBlank(version)) {
                    break;
                }

                file = new File(url.getFile());

                if (!file.exists()) {
                    break;
                }

                path = file.getAbsolutePath() + ComponentPackUtils.SUFFIX;

                ComponentPackUtils.log.debug("CP named " + name + " was found at " + path); //$NON-NLS-1$ //$NON-NLS-2$
                packs.put(name, new JDEInfo(name, path, version));
            }
        } catch (final Throwable e) {
            ComponentPackUtils.log.error(e.getMessage(), e);
        }
    }
    return packs;
}

From source file:com.haulmont.cuba.gui.data.impl.EntityCopyUtils.java

private static boolean isNotLoadedAttributeException(Throwable e) {
    return e instanceof IllegalStateException
            || e instanceof org.eclipse.persistence.exceptions.ValidationException && e.getMessage() != null
                    && e.getMessage().contains(
                            "An attempt was made to traverse a relationship using indirection that had a null Session");
}

From source file:com.evolveum.midpoint.web.component.message.OpResult.java

public static OpResult getOpResult(PageBase page, OperationResult result)
        throws SchemaException, RuntimeException {
    OpResult opResult = new OpResult();
    Validate.notNull(result, "Operation result must not be null.");
    Validate.notNull(result.getStatus(), "Operation result status must not be null.");

    opResult.message = result.getMessage();
    opResult.operation = result.getOperation();
    opResult.status = result.getStatus();
    opResult.count = result.getCount();/*from ww w . j ava2  s .  c o m*/

    if (result.getCause() != null) {
        Throwable cause = result.getCause();
        opResult.exceptionMessage = cause.getMessage();

        Writer writer = new StringWriter();
        cause.printStackTrace(new PrintWriter(writer));
        opResult.exceptionsStackTrace = writer.toString();
    }

    if (result.getParams() != null) {
        for (Map.Entry<String, Serializable> entry : result.getParams().entrySet()) {
            String paramValue = null;
            Object value = entry.getValue();
            if (value != null) {
                paramValue = value.toString();
            }

            opResult.getParams().add(new Param(entry.getKey(), paramValue));
        }
    }

    if (result.getContext() != null) {
        for (Map.Entry<String, Serializable> entry : result.getContext().entrySet()) {
            String contextValue = null;
            Object value = entry.getValue();
            if (value != null) {
                contextValue = value.toString();
            }

            opResult.getContexts().add(new Context(entry.getKey(), contextValue));
        }
    }

    if (result.getSubresults() != null) {
        for (OperationResult subresult : result.getSubresults()) {
            opResult.getSubresults().add(OpResult.getOpResult(page, subresult));
        }
    }

    try {
        OperationResultType resultType = result.createOperationResultType();
        ObjectFactory of = new ObjectFactory();
        opResult.xml = page.getPrismContext().serializeAtomicValue(of.createOperationResult(resultType),
                PrismContext.LANG_XML);
    } catch (SchemaException | RuntimeException ex) {
        String m = "Can't create xml: " + ex;
        //         error(m);
        opResult.xml = "<?xml version='1.0'?><message>" + StringEscapeUtils.escapeXml(m) + "</message>";
        throw ex;
    }
    return opResult;
}

From source file:com.jaeksoft.searchlib.Logging.java

public final static void error(Throwable e) {
    if (noLogger(System.out, e.getMessage(), e))
        return;/*from   w w w .  j  av  a 2 s. co m*/
    logger.error(e.getMessage(), e);
}

From source file:com.siberhus.tdfl.FieldDataException.java

protected static String translate(Throwable e) {
    Throwable rootCause = ExceptionUtils.getRootCause(e);
    if (rootCause != null) {
        e = rootCause;//from w w  w  . j  av a 2  s  .  com
    }
    if (!StringUtils.isBlank(e.getMessage())) {
        return e.getMessage();
    }
    return e.getClass().getSimpleName();
}

From source file:com.lidroid.util.OtherUtils.java

public static long getAvailableSpace(File dir) {
    try {/*  w w w.j  a  v  a 2s  .  co m*/
        final StatFs stats = new StatFs(dir.getPath());
        return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks();
    } catch (Throwable e) {
        Logger.e(e.getMessage(), e);
        return -1;
    }

}

From source file:com.lipy.android.http.exception.ActionException.java

public static Throwable handleException(java.lang.Throwable e) {

    Log.e("Novate", e.getMessage());
    Throwable ex;//  w  w w. j  a  va  2  s .  com
    if (e instanceof HttpException) {
        HttpException httpException = (HttpException) e;
        ex = new Throwable(e, ERROR.HTTP_ERROR);
        switch (httpException.code()) {
        case UNAUTHORIZED:
            ex.setMessage("?");
        case FORBIDDEN:
            ex.setMessage("?");
        case NOT_FOUND:
            ex.setMessage("??");
        case REQUEST_TIMEOUT:
            ex.setMessage("");
        case GATEWAY_TIMEOUT:
            ex.setMessage("?");
        case INTERNAL_SERVER_ERROR:
            ex.setMessage("?");
        case BAD_GATEWAY:
            ex.setMessage("");
        case SERVICE_UNAVAILABLE:
            ex.setMessage("???");
        case ACCESS_DENIED:
            ex.setMessage("");
        case HANDEL_ERRROR:
            ex.setMessage("??");
        default:
            ex.setMessage(e.getMessage());
            break;
        }
        ex.setCode(httpException.code());
        return ex;
    } else if (e instanceof ServerException) {
        ServerException resultException = (ServerException) e;
        ex = new Throwable(resultException, resultException.code);
        ex.setMessage(resultException.getMessage());
        return ex;
    } else if (e instanceof JsonParseException || e instanceof JSONException || e instanceof ParseException) {
        ex = new Throwable(e, ERROR.PARSE_ERROR);
        ex.setMessage("?");
        return ex;
    } else if (e instanceof ConnectException) {
        ex = new Throwable(e, ERROR.NETWORD_ERROR);
        ex.setMessage("");
        return ex;
    } else if (e instanceof javax.net.ssl.SSLHandshakeException) {
        ex = new Throwable(e, ERROR.SSL_ERROR);
        ex.setMessage("??");
        return ex;
    } else if (e instanceof java.security.cert.CertPathValidatorException) {
        ex = new Throwable(e, ERROR.SSL_NOT_FOUND);
        ex.setMessage("?");
        return ex;
    } else if (e instanceof ConnectTimeoutException) {
        ex = new Throwable(e, ERROR.TIMEOUT_ERROR);
        ex.setMessage("");
        return ex;
    } else if (e instanceof java.net.SocketTimeoutException) {
        ex = new Throwable(e, ERROR.TIMEOUT_ERROR);
        ex.setMessage("");
        return ex;
    } else if (e instanceof ClassCastException) {
        ex = new Throwable(e, ERROR.FORMAT_ERROR);
        ex.setMessage("?");
        return ex;
    } else if (e instanceof NullPointerException) {
        ex = new Throwable(e, ERROR.NULL);
        ex.setMessage("?");
        return ex;
    } else if (e instanceof FormatException) {
        FormatException resultException = (FormatException) e;
        ex = new Throwable(resultException, resultException.code);
        ex.setMessage(resultException.message);
        return ex;
    } else {

        ex = new Throwable(e, ERROR.UNKNOWN);
        ex.setMessage(e.getLocalizedMessage());
        return ex;
    }
}

From source file:com.jaeksoft.searchlib.Logging.java

public final static void warn(Throwable e) {
    if (noLogger(System.err, e.getMessage(), e))
        return;//from w w  w . ja  va  2 s.  co m
    if (isShowStackTrace())
        logger.warn(e.getMessage(), e);
    else
        logger.warn(e.getMessage());
}

From source file:com.jaeksoft.searchlib.Logging.java

public final static void info(Throwable e) {
    if (noLogger(System.out, e.getMessage(), e))
        return;//ww w  . j av a 2s  . c  o  m
    if (isShowStackTrace())
        logger.info(e.getMessage(), e);
    else
        logger.info(e.getMessage());
}

From source file:com.jaeksoft.searchlib.Logging.java

public final static void debug(Throwable e) {
    if (noLogger(System.out, e.getMessage(), e))
        return;/*from   w  w w  .j a v  a 2  s.c  om*/
    if (isShowStackTrace())
        logger.debug(e.getMessage(), e);
    else
        logger.debug(e.getMessage());
}