Example usage for org.apache.commons.lang3.exception ExceptionUtils getStackTrace

List of usage examples for org.apache.commons.lang3.exception ExceptionUtils getStackTrace

Introduction

In this page you can find the example usage for org.apache.commons.lang3.exception ExceptionUtils getStackTrace.

Prototype

public static String getStackTrace(final Throwable throwable) 

Source Link

Document

Gets the stack trace from a Throwable as a String.

The result of this method vary by JDK version as this method uses Throwable#printStackTrace(java.io.PrintWriter) .

Usage

From source file:com.trenako.web.infrastructure.LogUtils.java

public static void logException(Logger log, Throwable ex) {
    log.error(ExceptionUtils.getStackTrace(ex));
}

From source file:de.pixida.logtest.designer.commons.ExceptionDialog.java

public static void showFatalException(final String title, final String message, final Throwable exception) {
    final Alert alert = new Alert(Alert.AlertType.ERROR);
    alert.initStyle(StageStyle.UTILITY);
    alert.setTitle("Error");
    alert.setHeaderText(title);//from  w w  w. j  a  va 2s.  com
    alert.setContentText(message);

    final Label label = new Label("Details:");

    final TextArea textArea = new TextArea(ExceptionUtils.getStackTrace(exception));
    textArea.setEditable(false);
    textArea.setWrapText(true);

    textArea.setMaxWidth(Double.MAX_VALUE);
    textArea.setMaxHeight(Double.MAX_VALUE);
    GridPane.setVgrow(textArea, Priority.ALWAYS);
    GridPane.setHgrow(textArea, Priority.ALWAYS);

    final GridPane expContent = new GridPane();
    expContent.setMaxWidth(Double.MAX_VALUE);
    expContent.add(label, 0, 0);
    expContent.add(textArea, 0, 1);

    alert.getDialogPane().setExpandableContent(expContent);

    alert.showAndWait();
}

From source file:com.mirth.connect.util.ErrorMessageBuilder.java

public static String buildErrorMessage(String errorType, String customMessage, Throwable e) {
    String errorSourceLine = null;

    // if the exception occurred during execution of the script, get the
    // line of code that caused the error
    if (e instanceof RhinoException) {
        errorSourceLine = ((RhinoException) e).lineSource();
    }//from w  w  w.  j  a v  a  2 s .c o m

    // construct the error message
    StringBuilder builder = new StringBuilder();
    String stackTrace = new String();

    if (e != null) {
        stackTrace = ExceptionUtils.getStackTrace(e);
    }

    builder.append(errorType);
    builder.append(" error");

    if (StringUtils.isNotBlank(errorSourceLine)) {
        builder.append(LINE_SEPARATOR);
        builder.append("ERROR SOURCE: ");
        builder.append(errorSourceLine);
    }

    if (StringUtils.isNotBlank(customMessage)) {
        builder.append(LINE_SEPARATOR);
        builder.append("ERROR MESSAGE: ");
        builder.append(customMessage);
    }

    if (StringUtils.isNotBlank(stackTrace)) {
        builder.append(LINE_SEPARATOR);
        builder.append(stackTrace);
    }

    return builder.toString();
}

From source file:io.parallec.core.util.PcStringUtils.java

/**
 * Prints the stack trace.//  w  ww . j  ava 2s. c  om
 *
 * @param t
 *            the throwable
 * @return the string
 */
public static String printStackTrace(Throwable t) {
    return t == null ? PcConstants.NA : ExceptionUtils.getStackTrace(t);

}

From source file:com.adobe.acs.commons.mcp.model.impl.ArchivedProcessFailure.java

public static ArchivedProcessFailure adapt(Failure source) {
    ArchivedProcessFailure dest = new ArchivedProcessFailure();
    if (source.getException() != null) {
        dest.time = source.getTime().getTime();
        dest.error = source.getException().getMessage();
        dest.stackTrace = ExceptionUtils.getStackTrace(source.getException());
    }/*w ww .  j  a va  2  s  .co  m*/
    dest.nodePath = source.getNodePath();
    return dest;
}

From source file:com.callidusrobotics.droptables.exception.HtmlWebApplicationException.java

protected static String getMessage(Throwable cause, int statusCode) {
    StringBuilder builder = new StringBuilder();
    builder.append("<html><head><title>");
    builder.append(statusCode);/*from www.j  av  a 2  s . co m*/
    builder.append(" Error</title></head><body><pre>");
    builder.append(ExceptionUtils.getStackTrace(cause));
    builder.append("</pre></body></html>");

    return builder.toString();
}

From source file:mamo.vanillaVotifier.utils.SubstitutionUtils.java

@NotNull
public static StrSubstitutor buildStrSubstitutor(@Nullable Entry<String, Object>... substitutions) {
    HashMap<String, Object> substitutionsMap = new HashMap<String, Object>();
    if (substitutions != null) {
        for (Entry<String, Object> substitution : substitutions) {
            if (substitution.getValue() != null) {
                if (!(substitution.getValue() instanceof Throwable)) {
                    substitutionsMap.put(substitution.getKey(), substitution.getValue());
                } else {
                    substitutionsMap.put(substitution.getKey(),
                            ExceptionUtils.getStackTrace((Throwable) substitution.getValue()));
                }/*w w  w  .ja  v a 2 s .  co m*/
            } else {
                substitutionsMap.put(substitution.getKey(), "");
            }
        }
    }
    return new StrSubstitutor(substitutionsMap);
}

From source file:com.mirth.connect.server.channel.LoggingTaskHandler.java

@Override
public void taskErrored(String channelId, Integer metaDataId, Exception e) {
    logger.error(ExceptionUtils.getStackTrace(e));
}

From source file:jp.co.ipublishing.aeskit.notification.NotificationRegister.java

/**
 * ?//from ww w . ja  v a 2s . c o  m
 *
 * @param context 
 * @param key     ?
 * @return Observable
 */
public static Observable<String> registerKey(@NonNull final Context context, @NonNull final String key) {
    return Observable.create(new Observable.OnSubscribe<String>() {
        @Override
        public void call(Subscriber<? super String> subscriber) {
            try {
                final String registrationId = GCMRegister.register(context, key);

                subscriber.onNext(registrationId);
                subscriber.onCompleted();

            } catch (IOException e) {
                Log.e(TAG, ExceptionUtils.getStackTrace(e));

                subscriber.onError(e);
            }
        }
    });
}

From source file:com.aurel.track.itemNavigator.viewPlugin.ViewPluginBL.java

public synchronized static IssueListViewPlugin getPlugin(String className) {
    if (cachePlugins == null) {
        cachePlugins = new HashMap<String, Class>();
    }//from ww  w .j av a 2s .com
    Class pluginClass = (Class) cachePlugins.get(className);
    if (pluginClass == null) {
        try {
            pluginClass = Class.forName(className);
        } catch (ClassNotFoundException e) {
            LOGGER.error(ExceptionUtils.getStackTrace(e));
            return null;
        }
        cachePlugins.put(className, pluginClass);
    }
    try {
        return (IssueListViewPlugin) pluginClass.newInstance();
    } catch (InstantiationException e) {
        LOGGER.error(ExceptionUtils.getStackTrace(e));
    } catch (IllegalAccessException e) {
        LOGGER.error(ExceptionUtils.getStackTrace(e));
    }
    return null;//plugin class problem
}