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.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskXMsg.CFAsteriskXMsgSchemaMessageFormatter.java

public static String formatRspnException(String separator, Throwable t) {
    String retval = "<RspnException "
            + CFLibXmlUtil.formatRequiredXmlString(null, "Name", t.getClass().getName())
            + CFLibXmlUtil.formatRequiredXmlString(separator, "Message", t.getMessage()) + " />";
    return (retval);
}

From source file:com.nextep.designer.dbgm.ui.handlers.ExportDiagramAsImageHandler.java

public static boolean save(final IEditorPart editorPart, final GraphicalViewer viewer,
        final String saveFilePath, final int format) {
    Assert.isNotNull(editorPart, DBGMUIMessages.getString("handler.diagramExport.nullEditorError")); //$NON-NLS-1$
    Assert.isNotNull(viewer, DBGMUIMessages.getString("handler.diagramExport.nullViewerError")); //$NON-NLS-1$
    Assert.isNotNull(saveFilePath, DBGMUIMessages.getString("handler.diagramExport.nullFilePathError")); //$NON-NLS-1$

    if (format != SWT.IMAGE_BMP && format != SWT.IMAGE_JPEG && format != SWT.IMAGE_ICO
            && format != SWT.IMAGE_GIF && format != SWT.IMAGE_PNG)
        throw new IllegalArgumentException(DBGMUIMessages.getString("handler.diagramExport.unsupportedFormat")); //$NON-NLS-1$

    UIJob j = new UIJob("Creating image from diagram") {

        @Override// ww w.  j a v a2s  .  c  o  m
        public IStatus runInUIThread(IProgressMonitor monitor) {
            try {
                monitor.beginTask("Exporting diagram to " + saveFilePath + "...", 100);
                monitor.worked(50);
                // Ensuring that the job dialog is visible to notfiy the user
                while (getDisplay().readAndDispatch()) {
                }
                saveEditorContentsAsImage(editorPart, viewer, saveFilePath, format);
                monitor.worked(45);
                Display.getDefault().asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        MessageDialog.openInformation(editorPart.getSite().getShell(),
                                DBGMUIMessages.getString("handler.diagramExport.exportSuccessTitle"), //$NON-NLS-1$
                                MessageFormat.format(
                                        DBGMUIMessages.getString("handler.diagramExport.exportSuccessMsg"), //$NON-NLS-1$
                                        saveFilePath));

                    }
                });
                monitor.done();
                return Status.OK_STATUS;
            } catch (Throwable ex) {
                log.error(DBGMUIMessages.getString("handler.diagramExport.saveErrorMsg") + ex.getMessage(), ex); //$NON-NLS-1$
                return new Status(IStatus.ERROR, DbgmUIPlugin.PLUGIN_ID,
                        DBGMUIMessages.getString("handler.diagramExport.saveErrorMsg") //$NON-NLS-1$
                                + ex.getMessage(),
                        ex);
            }
        }
    };
    j.setUser(true);
    j.schedule();
    return true;
}

From source file:Main.java

private static void handlePluginException(Throwable pluginException) {
    /*/*from   w ww .  j  a v  a  2 s. co  m*/
     * We don't want errors from the plugin to affect normal flow.
     * Since the plugin should never throw this is a safety net
     * and will complain loudly to System.err so it gets fixed.
     */
    System.err
            .println("RxJavaErrorHandler threw an Exception. It shouldn't. => " + pluginException.getMessage());
    pluginException.printStackTrace();
}

From source file:com.opengamma.component.tool.ToolContextUtils.java

private static ToolContext createToolContextByHttp(String configResourceLocation,
        Class<? extends ToolContext> toolContextClazz, List<String> classifierChain) {
    configResourceLocation = StringUtils.stripEnd(configResourceLocation, "/");
    if (configResourceLocation.endsWith("/jax") == false) {
        configResourceLocation += "/jax";
    }//from  ww  w.  ja v  a  2 s . co m

    // Get the remote component server using the supplied URI
    RemoteComponentServer remoteComponentServer = new RemoteComponentServer(URI.create(configResourceLocation));
    ComponentServer componentServer = remoteComponentServer.getComponentServer();

    // Attempt to build a tool context of the specified type
    ToolContext toolContext;
    try {
        toolContext = toolContextClazz.newInstance();
    } catch (Throwable t) {
        return null;
    }

    // Populate the tool context from the remote component server
    for (MetaProperty<?> metaProperty : toolContext.metaBean().metaPropertyIterable()) {
        if (!metaProperty.name().equals("contextManager")) {
            try {
                ComponentInfo componentInfo = getComponentInfo(componentServer, classifierChain,
                        metaProperty.propertyType());
                if (componentInfo == null) {
                    s_logger.warn("Unable to populate tool context '" + metaProperty.name()
                            + "', no appropriate component found on the server");
                    continue;
                }
                if (ViewProcessor.class.equals(componentInfo.getType())) {
                    final JmsConnector jmsConnector = createJmsConnector(componentInfo);
                    final ScheduledExecutorService scheduler = Executors
                            .newSingleThreadScheduledExecutor(new NamedThreadFactory("rvp"));
                    ViewProcessor vp = new RemoteViewProcessor(componentInfo.getUri(), jmsConnector, scheduler);
                    toolContext.setViewProcessor(vp);
                    toolContext.setContextManager(new Closeable() {
                        @Override
                        public void close() throws IOException {
                            scheduler.shutdownNow();
                            jmsConnector.close();
                        }
                    });
                } else {
                    String clazzName = componentInfo.getAttribute(ComponentInfoAttributes.REMOTE_CLIENT_JAVA);
                    if (clazzName == null) {
                        s_logger.warn("Unable to populate tool context '" + metaProperty.name()
                                + "', no remote access class found");
                        continue;
                    }
                    Class<?> clazz = Class.forName(clazzName);
                    metaProperty.set(toolContext,
                            clazz.getConstructor(URI.class).newInstance(componentInfo.getUri()));
                    s_logger.info("Populated tool context '" + metaProperty.name() + "' with "
                            + metaProperty.get(toolContext));
                }
            } catch (Throwable ex) {
                s_logger.warn(
                        "Unable to populate tool context '" + metaProperty.name() + "': " + ex.getMessage());
            }
        }
    }
    return toolContext;
}

From source file:com.opengamma.language.connector.Main.java

/**
 * Entry point from the service wrapper - starts the service.
 * /* w  w w  . ja v a2  s  . co m*/
 * @return null if the service started properly, otherwise a string for display to the user describing why the stack wasn't started
 */
public static String svcStart() {
    try {
        s_logger.info("Starting OpenGamma language integration service");
        s_springContext = new LanguageSpringContext();
        return null;
    } catch (final BeanCreationException e) {
        s_logger.error("Exception thrown", e);
        Throwable t = e;
        do {
            t = t.getCause();
        } while (t instanceof BeanCreationException);
        if (t != null) {
            return t.getMessage();
        } else {
            return e.getMessage();
        }
    } catch (final Throwable t) {
        s_logger.error("Exception thrown", t);
        return t.getMessage();
    }
}

From source file:com.tc.management.JMXConnectorProxy.java

static boolean isAuthenticationException(IOException ioe) {
    Throwable t = ioe;

    while (t != null) {
        if (t instanceof NotSerializableException) {
            String detailMessage = t.getMessage();
            if ("com.sun.jndi.ldap.LdapCtx".equals(detailMessage)) {
                return true;
            }//w  w  w  .j  av a 2 s  .c  om
        }
        t = t.getCause();
    }

    return false;
}

From source file:org.cleverbus.core.common.exception.ExceptionTranslator.java

/**
 * Returns recursively error messages from the whole exception hierarchy.
 *
 * @param ex the exception/*  w  w  w  .  j a va 2s . c o  m*/
 * @return exception message
 */
private static String getMessagesInExceptionHierarchy(Throwable ex) {
    Assert.notNull(ex, "the ex must not be null");

    // use a util that can handle recursive cause structure:
    Throwable[] hierarchy = ExceptionUtils.getThrowables(ex);

    StringBuilder messages = new StringBuilder();
    for (Throwable throwable : hierarchy) {
        if (messages.length() > 0) {
            messages.append(" => ");
        }
        messages.append(throwable.getClass().getSimpleName()).append(": ").append(throwable.getMessage());
    }

    return messages.toString();
}

From source file:de.jlo.talendcomp.json.TypeUtil.java

/**
 * concerts the string format into a Date
 * @param dateString/*from w w w.  j  av  a  2 s  .  co m*/
 * @param pattern
 * @return the resulting Date
 */
public static Date convertToDate(String dateString, String pattern) throws Exception {
    if (dateString == null || dateString.isEmpty()) {
        return null;
    }
    if (pattern == null) {
        pattern = DEFAULT_DATE_PATTERN;
    }
    try {
        FastDateFormat sdf = FastDateFormat.getInstance(pattern);
        Date date = null;
        try {
            date = sdf.parse(dateString);
        } catch (ParseException pe) {
            date = GenericDateUtil.parseDate(dateString);
        }
        return date;
    } catch (Throwable t) {
        throw new Exception("Failed to convert string to date:" + t.getMessage(), t);
    }
}

From source file:org.commonjava.aprox.bind.jaxrs.util.ResponseUtils.java

public static CharSequence formatEntity(final Throwable error, final String message) {
    final StringWriter sw = new StringWriter();
    if (message != null) {
        sw.append(message);//from w  w w  . jav a 2 s .  c  om
        sw.append("\nError was:\n\n");
    }

    sw.append(error.getMessage());

    final Throwable cause = error.getCause();
    if (cause != null) {
        sw.append("\n\n");
        cause.printStackTrace(new PrintWriter(sw));
    }

    sw.write('\n');

    return sw.toString();
}

From source file:com.evolveum.midpoint.util.logging.LoggingUtils.java

private static void logExceptionInternal(Level first, Level second, Trace LOGGER, String message, Throwable ex,
        Object... objects) {// w  ww.  j  a  v a  2 s .  c om
    Validate.notNull(LOGGER, "Logger can't be null.");
    Validate.notNull(ex, "Exception can't be null.");

    List<Object> args = new ArrayList<>();
    args.addAll(Arrays.asList(objects));
    args.add(ex.getMessage() + " (" + ex.getClass() + ")");

    if (!first.equals(second)) {
        log(LOGGER, first, message + ", reason: {}", args.toArray());
    }
    // Add exception to the list. It will be the last argument without {} in the message,
    // therefore the stack trace will get logged
    args.add(ex);
    log(LOGGER, second, message + ".", args.toArray());
}