Example usage for java.lang Throwable getLocalizedMessage

List of usage examples for java.lang Throwable getLocalizedMessage

Introduction

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

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:org.polymap.core.operation.actions.SaveChangesAction.java

public void run(IAction _action) {
    try {/*from   w  w  w .  j  av a  2  s.  c o m*/
        operationSupport.saveChanges();
    } catch (Throwable e) {
        PolymapWorkbench.handleError(CorePlugin.PLUGIN_ID, this, e.getLocalizedMessage(), e);
    }
}

From source file:com.microsoft.alm.plugin.idea.services.LocalizationServiceImpl.java

/**
 * Gets the localized exception message/*from   w  ww .ja  v a 2 s  .c o  m*/
 *
 * @param t
 * @return localized string
 */
public String getExceptionMessage(final Throwable t) {

    //get exception message
    String message = t.getLocalizedMessage();

    if (t instanceof TeamServicesException) {
        final String key = ((TeamServicesException) t).getMessageKey();
        if (keysMap.containsKey(key)) {
            message = getLocalizedMessage(keysMap.get(key));
        }
    }

    //exception message is not set
    //Use the message on the cause if there is one
    if (StringUtils.isEmpty(message) && t.getCause() != null) {
        if (t.getCause() instanceof TeamServicesException) {
            final String key = ((TeamServicesException) t).getMessageKey();
            if (keysMap.containsKey(key)) {
                message = getLocalizedMessage(keysMap.get(key));
            }
        } else {
            message = t.getCause().getLocalizedMessage();
        }
    }

    //No message on the exception and the cause, just use description from toString
    if (StringUtils.isEmpty(message)) {
        message = t.toString();
    }

    return message;
}

From source file:com.anrisoftware.prefdialog.miscswing.logwindowdock.ErrorNode.java

private Object appendStackTrace(String description, Throwable ex) {
    StringBuilder b = new StringBuilder(description);
    b.append(ex.getLocalizedMessage()).append('\n');
    String stackTrace = join(getRootCauseStackTrace(ex), '\n');
    b.append(stackTrace);//from w  w w .  ja  v  a2 s . com
    return b.toString();
}

From source file:org.thehecklers.MQTTSubscriber.java

public MQTTSubscriber(String address) {
    this.address = address;
    try {//from w  w  w. j  av  a2  s . co m
        client = new MqttAsyncClient(address, "reading");
        client.setCallback(this);
        client.connect(null, new IMqttActionListener() {
            @Override
            public void onSuccess(IMqttToken imt) {
                try {
                    client.subscribe("reading/temp", 0);
                } catch (MqttException ex) {
                    Logger.getLogger(MQTTSubscriber.class.getName()).log(Level.SEVERE, null, ex);
                }
            }

            @Override
            public void onFailure(IMqttToken imt, Throwable thrwbl) {
                System.out.println("Unable to connect temp client: " + thrwbl.getLocalizedMessage());
            }
        });
    } catch (MqttException ex) {
        System.out.println("Well, this is awkward...");
        //Logger.getLogger(A4jVideoViewport.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:de.fhg.iais.asc.commons.exceptions.AscReportableErrorException.java

private String getAllErrorMessages(Throwable e, ArrayList<String> list) {
    if (e != null) {

        if (!Strings.isNullOrEmpty(e.getLocalizedMessage())) {
            String message = e.getLocalizedMessage().trim();
            if (!list.contains(message)) {
                list.add(message);//ww w .  j  av  a 2  s.  co  m
            }
        }
        return getAllErrorMessages(e.getCause(), list);
    } else {
        return list.toString();
    }
}

From source file:facebook.TiRequestListener.java

private void complete(Throwable t) {
    Log.e("FacebookModule", "Request error for '" + callPath + "' call: " + t.getLocalizedMessage(), t);
    doCallback(buildEventArgs(false, t));
}

From source file:org.pgptool.gui.tools.ConsoleExceptionUtils.java

public static String getAllMessages(Throwable t) {
    if (t == null)
        return "";

    StringBuffer ret = new StringBuffer();

    Throwable cur = t;
    while (cur != null) {
        if (cur == cur.getCause())
            break;

        if (ret.length() > 0) {
            ret.append(" -> ");
        }//from  w  w w  .j  a v a  2s. c o m

        if (cur instanceof FieldValidationException) {
            FieldValidationException fve = (FieldValidationException) cur;
            ret.append(buildMessageForFve(fve, LocaleContextHolder.getLocale()));
        } else if (cur instanceof HasMessageCode) {
            ret.append(I18nUtils.buildMessage((HasMessageCode) cur, ac()));
        } else {
            try {
                String className = cur.getClass().getName();
                String messageMappingForClassName = Messages.get(className, cur.getMessage());
                if (className.equals(messageMappingForClassName)) {
                    throw new NoSuchMessageException(className);
                }
                ret.append(messageMappingForClassName);
            } catch (NoSuchMessageException nfe) {
                ret.append(cur.getLocalizedMessage());
            }
        }

        cur = cur.getCause();
    }

    return ret.toString();
}

From source file:org.opencms.ui.CmsVaadinErrorHandler.java

/**
 * @see com.vaadin.server.DefaultErrorHandler#error(com.vaadin.server.ErrorEvent)
 */// w  w  w.  j av  a  2  s. c  om
@Override
public void error(ErrorEvent event) {

    super.error(event);
    if (m_ui != null) {
        m_ui.onError();
    }
    Throwable throwable = event.getThrowable();
    if (!(throwable instanceof SocketException)) {
        LOG.error(throwable.getLocalizedMessage(), throwable);
    }
}

From source file:org.pentaho.platform.dataaccess.datasource.wizard.SwingDatasourceEditor.java

public SwingDatasourceEditor(final IXulAsyncDatasourceService datasourceService,
        final IXulAsyncConnectionService connectionService) {
    try {// w w w  .jav  a  2  s  . com
        XulDomContainer container = new SwingXulLoader()
                .loadXul("org/pentaho/platform/dataaccess/datasource/wizard/public/datasourceEditorDialog.xul");

        runner = new SwingXulRunner();
        runner.addContainer(container);

        BindingFactory bf = new DefaultBindingFactory();
        bf.setDocument(container.getDocumentRoot());

        datasourceController = new DatasourceController();
        datasourceController.setBindingFactory(bf);
        container.addEventHandler(datasourceController);

        final CsvDatasourceController csvDatasourceController = new CsvDatasourceController();
        csvDatasourceController.setBindingFactory(bf);
        container.addEventHandler(csvDatasourceController);

        final RelationalDatasourceController relationalDatasourceController = new RelationalDatasourceController();
        relationalDatasourceController.setBindingFactory(bf);
        container.addEventHandler(relationalDatasourceController);

        final ConnectionController connectionController = new ConnectionController();
        container.addEventHandler(connectionController);

        connectionController.setService(connectionService);

        datasourceController.setService(datasourceService);

        connectionService.getConnections(new XulServiceCallback<List<IConnection>>() {

            public void error(String message, Throwable error) {
                System.out.println(error.getLocalizedMessage());
            }

            public void success(List<IConnection> connections) {
                DatasourceModel datasourceModel = new DatasourceModel();
                datasourceModel.getRelationalModel().setConnections(connections);
                datasourceController.setDatasourceModel(datasourceModel);
                connectionController.setDatasourceModel(datasourceModel);
                csvDatasourceController.setDatasourceModel(datasourceModel);
                relationalDatasourceController.setDatasourceModel(datasourceModel);

                try {
                    runner.initialize();
                } catch (XulException e) {
                    log.error("error starting Xul application", e);
                }
            }

        });
    } catch (XulException e) {
        log.error("error loading Xul application", e);
    }
}

From source file:com.microsoft.alm.plugin.idea.common.services.LocalizationServiceImpl.java

/**
 * Gets the localized exception message/* w  w  w  .  j a v  a2 s  . co m*/
 *
 * @param t
 * @return localized string
 */
public String getExceptionMessage(final Throwable t) {

    //get exception message
    String message = t.getLocalizedMessage();

    if (t instanceof LocalizedException) {
        final LocalizedException localizedException = (LocalizedException) t;
        final String key = localizedException.getMessageKey();
        if (keysMap.containsKey(key)) {
            message = getLocalizedMessage(keysMap.get(key),
                    (Object[]) localizedException.getMessageParameters());
        }
    }

    //exception message is not set
    //Use the message on the cause if there is one
    if (StringUtils.isEmpty(message) && t.getCause() != null) {
        if (t.getCause() instanceof LocalizedException) {
            final LocalizedException localizedException = (LocalizedException) t.getCause();
            final String key = localizedException.getMessageKey();
            if (keysMap.containsKey(key)) {
                message = getLocalizedMessage(keysMap.get(key),
                        (Object[]) localizedException.getMessageParameters());
            }
        } else {
            message = t.getCause().getLocalizedMessage();
        }
    }

    //No message on the exception and the cause, just use description from toString
    if (StringUtils.isEmpty(message)) {
        message = t.toString();
    }

    return message;
}