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.varaneckas.hawkscope.Version.java

/**
 * Formats bug report from exception/*  w  w  w  .  j  a  v  a 2  s . c  o m*/
 * 
 * @param e cause of possible bug
 * @return formatted report
 */
public static String getBugReport(final Throwable e) {
    final StringBuilder sb = new StringBuilder(300);
    final Writer stringWriter = new StringWriter();
    final PrintWriter w = new PrintWriter(stringWriter);
    e.printStackTrace(w);
    sb.append("Hawkscope Bug Report").append('\n').append(SEPARATOR)
            .append(e.getMessage().replaceAll(": ", ":\n")).append('\n').append(SEPARATOR)
            .append(stringWriter.toString()).append('\n').append(SEPARATOR).append(getEnvironmentReport());
    return sb.toString();
}

From source file:com.espertech.esper.core.ResultDeliveryStrategyImpl.java

/**
 * Handle the exception, displaying a nice message and converting to {@link EPException}.
 * @param logger is the logger to use for error logging
 * @param t is the throwable/* www .ja  v  a2  s .  c  o  m*/
 * @param params the method parameters
 * @param subscriber the object to deliver to
 * @param method the method to call
 * @throws EPException converted from the passed invocation exception
 */
protected static void handleThrowable(Log logger, Throwable t, Object[] params, Object subscriber,
        FastMethod method) {
    String message = "Unexpected exception when invoking method '" + method.getName()
            + "' on subscriber class '" + subscriber.getClass().getSimpleName() + "' for parameters "
            + ((params == null) ? "null" : Arrays.toString(params)) + " : " + t.getClass().getSimpleName()
            + " : " + t.getMessage();
    logger.error(message, t);
}

From source file:com.revolsys.util.JavaBeanUtil.java

public static <T> T invokeConstructor(final Constructor<? extends T> constructor, final Object... args) {
    try {//w  w w.j  av a  2s.c om
        final T object = constructor.newInstance(args);
        return object;
    } catch (final RuntimeException e) {
        throw e;
    } catch (final Error e) {
        throw e;
    } catch (final InvocationTargetException e) {
        final Throwable t = e.getTargetException();
        if (t instanceof RuntimeException) {
            throw (RuntimeException) t;
        } else if (t instanceof Error) {
            throw (Error) t;
        } else {
            throw new RuntimeException(t.getMessage(), t);
        }
    } catch (final Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:com.revolsys.util.JavaBeanUtil.java

@SuppressWarnings("unchecked")
public static <T> T method(final Object object, final String methodName, final Object... args) {
    try {//  ww w .  j ava 2s.  co m
        return (T) MethodUtils.invokeMethod(object, methodName, args);
    } catch (final RuntimeException e) {
        throw e;
    } catch (final Error e) {
        throw e;
    } catch (final InvocationTargetException e) {
        final Throwable t = e.getTargetException();
        if (t instanceof RuntimeException) {
            throw (RuntimeException) t;
        } else if (t instanceof Error) {
            throw (Error) t;
        } else {
            throw new RuntimeException(t.getMessage(), t);
        }
    } catch (final Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:io.stallion.monitoring.ExceptionInfo.java

public static ExceptionInfo newForException(Throwable e) {
    ExceptionInfo info = new ExceptionInfo();
    info.thrownAt = utcNow();//from   w w  w . j  a v  a  2 s .  c  o m
    info.stackTraces = ExceptionUtils.getRootCauseStackTrace(e);
    if (e instanceof InvocationTargetException) {
        e = ((InvocationTargetException) e).getTargetException();
    }
    info.className = e.getClass().getSimpleName();
    info.message = e.getMessage();
    info.requestUrl = request().getRequestUrl();
    info.requestUrlWithQuery = request().getRequestUrlWithQuery();
    info.requestMethod = request().getMethod();
    info.remoteAddr = request().getRemoteAddr();
    info.actualIp = request().getActualIp();
    info.requestHeaders = map();
    for (String name : Collections.list(request().getHeaderNames())) {
        info.requestHeaders.put(name, request().getHeader(name));
    }
    try {
        info.setRequestBody(request().getContent());
    } catch (RuntimeException e2) {
        Log.info("Error logging the exception - could not get the request body: {0}", e2);
    }
    if (!Context.getUser().isAnon()) {
        info.setEmail(Context.getUser().getEmail());
        info.setUsername(Context.getUser().getUsername());
        info.setUserId(Context.getUser().getId());
        info.setValetId(Context.getValetUserId());
    }
    return info;
}

From source file:net.sourceforge.atunes.kernel.modules.player.PlayerHandler.java

private static void handlePlayerError(Throwable t) {
    getLogger().error(LogCategories.PLAYER, StringUtils.getString("Player Error: ", t));
    getLogger().error(LogCategories.PLAYER, t);
    VisualHandler.getInstance().showErrorDialog(t.getMessage());
}

From source file:org.eclipse.cft.server.core.internal.CloudErrorUtil.java

public static CoreException toCoreException(String message, Throwable error) {
    if (message == null) {
        message = Messages.ERROR_UNKNOWN;
    }/*from ww  w.  j a v a2 s.  c o  m*/
    if (error != null) {
        if (error.getMessage() != null) {
            message += " - " + error.getMessage(); //$NON-NLS-1$
        }
        return new CoreException(CloudFoundryPlugin.getErrorStatus(message, error));
    } else {
        return new CoreException(CloudFoundryPlugin.getErrorStatus(message));
    }
}

From source file:com.espertech.esper.core.service.ResultDeliveryStrategyImpl.java

/**
 * Handle the exception, displaying a nice message and converting to {@link EPException}.
 * @param logger is the logger to use for error logging
 * @param t is the throwable/*from w  w  w.  j  av  a  2 s .  co m*/
 * @param parameters the method parameters
 * @param subscriber the object to deliver to
 * @param method the method to call
 * @throws EPException converted from the passed invocation exception
 */
protected static void handleThrowable(Log logger, Throwable t, Object[] parameters, Object subscriber,
        FastMethod method) {
    String message = "Unexpected exception when invoking method '" + method.getName()
            + "' on subscriber class '" + subscriber.getClass().getSimpleName() + "' for parameters "
            + ((parameters == null) ? "null" : Arrays.toString(parameters)) + " : "
            + t.getClass().getSimpleName() + " : " + t.getMessage();
    logger.error(message, t);
}

From source file:mobisocial.metrics.MusubiExceptionHandler.java

static JSONObject jsonForException(Context context, Throwable ex, boolean caught) {
    JSONObject json = new JSONObject();
    try {/*from   w  w w  .  jav  a2  s .  c o  m*/
        Writer traceWriter = new StringWriter();
        PrintWriter printer = new PrintWriter(traceWriter);
        ex.printStackTrace(printer);
        json.put("type", "exception");
        json.put("caught", caught);
        json.put("app", context.getPackageName());
        json.put("message", ex.getMessage());
        json.put("trace", traceWriter.toString());
        json.put("timestamp", Long.toString(new Date().getTime()));

        boolean devmode = MusubiBaseActivity.isDeveloperModeEnabled(context);
        json.put("musubi_devmode", Boolean.toString(devmode));
        if (devmode) {
            IdentitiesManager im = new IdentitiesManager(App.getDatabaseSource(context));
            MIdentity id = im.getMyDefaultIdentity();
            String user = "Unknown";
            if (id != null) {
                user = UiUtil.safeNameForIdentity(id);
            }
            json.put("musubi_devmode_user_id", user);
            user = App.getMusubi(context).userForLocalDevice(null).getName();
            json.put("musubi_devmode_user_name", user);
        }
        try {
            PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
            json.put("musubi_version_name", info.versionName);
            json.put("musubi_version_code", Integer.toString(info.versionCode));
        } catch (NameNotFoundException e) {
            // shouldn't happen, but not fatal.
        }
        json.put("android_api", Integer.toString(Build.VERSION.SDK_INT));
        json.put("android_release", Build.VERSION.RELEASE);
        json.put("android_model", Build.MODEL);
        json.put("android_make", Build.MANUFACTURER);
    } catch (JSONException e) {
    }
    return json;
}

From source file:com.zimbra.common.service.ServiceException.java

public static ServiceException PROXY_ERROR(Throwable cause, String url) {
    return new ServiceException(
            "error while proxying request to target server: "
                    + (cause != null ? cause.getMessage() : "unknown reason"),
            PROXY_ERROR, RECEIVERS_FAULT, cause, new InternalArgument(URL, url, Argument.Type.STR));
}