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.geoserver.catalog.ResourcePool.java

void fireDisposed(DataStoreInfo dataStore, DataAccess da) {
    for (Listener l : listeners) {
        try {/*  w ww  . j av  a  2 s .  co m*/
            l.disposed(dataStore, da);
        } catch (Throwable t) {
            LOGGER.warning("Resource pool listener threw error");
            LOGGER.log(Level.INFO, t.getLocalizedMessage(), t);
        }
    }
}

From source file:org.geoserver.catalog.ResourcePool.java

void fireDisposed(FeatureTypeInfo featureType, FeatureType ft) {
    for (Listener l : listeners) {
        try {//from w  ww . java 2 s. c  o  m
            l.disposed(featureType, ft);
        } catch (Throwable t) {
            LOGGER.warning("Resource pool listener threw error");
            LOGGER.log(Level.INFO, t.getLocalizedMessage(), t);
        }
    }
}

From source file:org.geoserver.catalog.ResourcePool.java

void fireDisposed(CoverageStoreInfo coverageStore, GridCoverageReader gcr) {
    for (Listener l : listeners) {
        try {/*from   w  ww  .ja  v a2  s .  co m*/
            l.disposed(coverageStore, gcr);
        } catch (Throwable t) {
            LOGGER.warning("Resource pool listener threw error");
            LOGGER.log(Level.INFO, t.getLocalizedMessage(), t);
        }
    }
}

From source file:com.sforce.dataset.DatasetUtilMain.java

public static boolean doAction(String action, PartnerConnection partnerConnection, DatasetUtilParams params) {

    if (action == null) {
        printUsage();//  w  w w .  j a va  2s . com
        System.out.println("\nERROR: Invalid action {" + action + "}");
        return false;
    }

    if (params.inputFile != null) {
        File tempFile = validateInputFile(params.inputFile, action);
        if (tempFile == null) {
            System.out.println("Inputfile {" + params.inputFile + "} is not valid");
            return false;
        }
    }

    if (params.dataset != null && !params.dataset.isEmpty()) {
        if (params.datasetLabel == null)
            params.datasetLabel = params.dataset;
        String santizedDatasetName = ExternalFileSchema.createDevName(params.dataset, "Dataset", 1, false);
        if (!params.dataset.equals(santizedDatasetName)) {
            System.out.println(
                    "\n Warning: dataset name can only contain alpha-numeric or '_', must start with alpha, and cannot end in '__c'");
            System.out.println("\n changing dataset name to: {" + santizedDatasetName + "}");
            params.dataset = santizedDatasetName;
        }
    }

    Charset fileCharset = null;
    if (params.fileEncoding != null && !params.fileEncoding.trim().isEmpty()) {
        try {
            fileCharset = Charset.forName(params.fileEncoding);
        } catch (Throwable e) {
            e.printStackTrace();
            System.out.println("\nERROR: Invalid fileEncoding {" + params.fileEncoding + "}");
            return false;
        }
    }

    if (action.equalsIgnoreCase("load")) {
        if (params.inputFile == null || params.inputFile.isEmpty()) {
            System.out.println("\nERROR: inputFile must be specified");
            return false;
        }

        if (params.dataset == null || params.dataset.isEmpty()) {
            System.out.println("\nERROR: dataset name must be specified");
            return false;
        }

        Session session = null;
        try {
            String orgId = null;
            orgId = partnerConnection.getUserInfo().getOrganizationId();
            session = Session.getCurrentSession(orgId, params.dataset, true);
            //               session = new Session(orgId,params.dataset);
            //                 ThreadContext threadContext = ThreadContext.get();
            //                 threadContext.setSession(session);
            session.start();
            try {
                boolean status = DatasetLoader.uploadDataset(params.inputFile, params.uploadFormat,
                        params.codingErrorAction, fileCharset, params.dataset, params.app, params.datasetLabel,
                        params.Operation, params.useBulkAPI, partnerConnection, System.out);
                if (status)
                    session.end();
                else
                    session.fail("Check sessionLog for details");
                return status;
            } catch (DatasetLoaderException e) {
                session.fail(e.getMessage());
                return false;
            }
        } catch (Exception e) {
            System.out.println();
            e.printStackTrace(System.out);
            if (session != null)
                session.fail(e.getLocalizedMessage());
            return false;
        }
    } else if (action.equalsIgnoreCase("detectEncoding")) {
        if (params.inputFile == null) {
            System.out.println("\nERROR: inputFile must be specified");
            return false;
        }

        try {
            CharsetChecker.detectCharset(new File(params.inputFile), System.out);
        } catch (Exception e) {
            e.printStackTrace(System.out);
            return false;
        }
    } else if (action.equalsIgnoreCase("uploadxmd")) {
        if (params.inputFile == null) {
            System.out.println("\nERROR: inputFile must be specified");
            return false;
        }

        if (params.dataset == null) {
            System.out.println("\nERROR: dataset must be specified");
            return false;
        }

        try {
            XmdUploader.uploadXmd(params.inputFile, params.dataset, null, null, partnerConnection);
        } catch (Exception e) {
            e.printStackTrace(System.out);
            return false;
        }
    } else if (action.equalsIgnoreCase("downloadxmd")) {
        if (params.dataset == null) {
            System.out.println("\nERROR: dataset alias must be specified");
            return false;
        }

        try {
            DatasetDownloader.downloadEM(params.dataset, partnerConnection);
        } catch (Exception e) {
            e.printStackTrace(System.out);
            return false;
        }
    } else if (action.equalsIgnoreCase("defineAugmentFlow")) {

        try {
            DatasetAugmenter.augmentEM(partnerConnection);
        } catch (Exception e) {
            e.printStackTrace(System.out);
            return false;
        }
    } else if (action.equalsIgnoreCase("defineExtractFlow")) {
        if (params.rootObject == null) {
            System.out.println("\nERROR: rootObject must be specified");
            return false;
        }

        try {
            SfdcExtracter.extract(params.rootObject, params.dataset, partnerConnection, params.rowLimit);
        } catch (Exception e) {
            e.printStackTrace(System.out);
            return false;
        }
    } else if (action.equalsIgnoreCase("downloadErrorFile")) {
        if (params.dataset == null) {
            System.out.println("\nERROR: dataset alias must be specified");
            return false;
        }

        try {
            DataFlowMonitorUtil.getJobsAndErrorFiles(partnerConnection, params.dataset);
        } catch (Exception e) {
            System.out.println();
            e.printStackTrace(System.out);
            return false;
        }

    } else {
        printUsage();
        System.out.println("\nERROR: Invalid action {" + action + "}");
        return false;
    }
    return true;
}

From source file:org.apache.synapse.message.store.impl.jms.JmsStore.java

public MessageProducer getProducer() {
    JmsProducer producer = new JmsProducer(this);
    producer.setId(nextProducerId());/* ww w . j av  a 2  s . c om*/
    Throwable throwable = null;
    Session session = null;
    javax.jms.MessageProducer messageProducer;
    boolean error = false;
    try {
        synchronized (producerLock) {
            if (producerConnection == null) {
                boolean ok = newWriteConnection();
                if (!ok) {
                    return producer;
                }
            }
        }
        try {
            session = newSession(producerConnection(), Session.AUTO_ACKNOWLEDGE, true);
        } catch (JMSException e) {
            synchronized (producerLock) {
                boolean ok = newWriteConnection();
                if (!ok) {
                    return producer;
                }
            }
            session = newSession(producerConnection(), Session.AUTO_ACKNOWLEDGE, true);
            logger.info(nameString() + " established a connection to the broker.");
        }
        messageProducer = newProducer(session);
        producer.setConnection(producerConnection()).setSession(session).setProducer(messageProducer);
    } catch (Throwable t) {
        error = true;
        throwable = t;
    }
    if (error) {
        String errorMsg = "Could not create a Message Producer for " + nameString() + ". Error:"
                + throwable.getLocalizedMessage();
        logger.error(errorMsg, throwable);
        synchronized (producerLock) {
            cleanup(producerConnection, session, true);
            producerConnection = null;
        }
        return producer;
    }
    if (logger.isDebugEnabled()) {
        logger.debug(nameString() + " created message producer " + producer.getId());
    }
    return producer;
}

From source file:org.apache.geode.internal.cache.tier.sockets.ClientHealthMonitor.java

/**
 * Takes care of unregistering from the _clientHeatBeats map.
 * //from ww  w  . j av a 2  s . co  m
 * @param proxyID The id of the client to be unregistered
 */
private void unregisterClient(ClientProxyMembershipID proxyID, boolean clientDisconnectedCleanly,
        Throwable clientDisconnectException) {
    boolean unregisterClient = false;
    synchronized (_clientHeartbeatsLock) {
        Map oldClientHeartbeats = this._clientHeartbeats;
        if (oldClientHeartbeats.containsKey(proxyID)) {
            unregisterClient = true;
            Map newClientHeartbeats = new HashMap(oldClientHeartbeats);
            newClientHeartbeats.remove(proxyID);
            this._clientHeartbeats = newClientHeartbeats;
        }
    }

    if (unregisterClient) {
        if (clientDisconnectedCleanly) {
            if (logger.isDebugEnabled()) {
                logger.debug(LocalizedMessage.create(
                        LocalizedStrings.ClientHealthMonitor_CLIENTHEALTHMONITOR_UNREGISTERING_CLIENT_WITH_MEMBER_ID_0,
                        new Object[] { proxyID }));
            }
        } else {
            logger.warn(LocalizedMessage.create(
                    LocalizedStrings.ClientHealthMonitor_CLIENTHEALTHMONITOR_UNREGISTERING_CLIENT_WITH_MEMBER_ID_0_DUE_TO_1,
                    new Object[] { proxyID, clientDisconnectException == null ? "Unknown reason"
                            : clientDisconnectException.getLocalizedMessage() }));
        }
        if (this.stats != null) {
            this.stats.incClientUnRegisterRequests();
        }
        expireTXStates(proxyID);
    }
}

From source file:com.aol.framework.helper.report.CustomizedReporter.java

private void generateExceptionReport(Throwable exception, ITestNGMethod method, String title,
        PrintWriter m_out) {/*from  w w  w.j av a 2  s . c o  m*/

    m_out.println("<p>" + exception.getClass() + ": " + title + "</p><p>");

    StackTraceElement[] s1 = exception.getStackTrace();
    Throwable t2 = exception.getCause();
    if (t2 == exception) {
        t2 = null;
    }
    int maxlines = Math.min(100, StackTraceTools.getTestRoot(s1, method));
    for (int x = 0; x <= maxlines; x++) {
        m_out.println((x > 0 ? "<br/>at " : "") + Utils.escapeHtml(s1[x].toString()));
    }
    if (maxlines < s1.length) {
        m_out.println("<br/>" + (s1.length - maxlines) + " lines not shown");
    }
    if (t2 != null) {
        generateExceptionReport(t2, method, "Caused by " + t2.getLocalizedMessage(), m_out);
    }
    m_out.println("</p>");
    m_out.flush();
}

From source file:com.silentcircle.silenttext.activity.AccountCreationActivity.java

@Override
public void onFinish(final Bundle arguments) {

    if (!tasks.isEmpty()) {
        return;//  w  ww . j  a va  2s.  co  m
    }

    tasks.add(AsyncUtils.execute(new AsyncTask<Void, Void, UsernamePasswordCredential>() {

        @Override
        protected UsernamePasswordCredential doInBackground(Void... params) {

            UserManager manager = SilentTextApplication.from(getActivity()).getUserManager();

            BasicUser user = new BasicUser();

            user.setFirstName(arguments.getCharSequence(AccountCreationFragment.EXTRA_FIRST_NAME));
            user.setLastName(arguments.getCharSequence(AccountCreationFragment.EXTRA_LAST_NAME));
            user.setEmailAddress(arguments.getCharSequence(AccountCreationFragment.EXTRA_EMAIL));

            CharSequence username = arguments.getCharSequence(AccountCreationFragment.EXTRA_USERNAME);
            CharSequence password = arguments.getCharSequence(AccountCreationFragment.EXTRA_PASSWORD);
            CharSequence licenseCode = arguments.getCharSequence(AccountCreationFragment.EXTRA_LICENSE_CODE);

            try {
                UsernamePasswordCredential credential = new UsernamePasswordCredential(username, password);
                manager.createUser(credential, user, licenseCode);
                return credential;
            } catch (HTTPException e) {
                onError(e);
            } catch (Throwable t) {
                onError(t);
            }
            return null;
        }

        protected void onError(HTTPException e) {
            try {
                String errorString = new String();
                JSONObject errorJSON = new JSONObject(e.getBody());

                if (errorJSON.has("error_fields")) {
                    JSONObject errorFieldsJSON = errorJSON.getJSONObject("error_fields");

                    if (errorFieldsJSON.length() > 0) {
                        if (errorFieldsJSON.has("license_code")) {
                            errorString = errorFieldsJSON.getJSONObject("license_code").getString("error_msg");
                        } else {
                            if (!StringUtils.isEmpty(
                                    JSONObjectParser.parseFault(JSONParser.parse(e.getBody())).getFields()[0]
                                            .getMessage())) {
                                errorString = JSONObjectParser.parseFault(JSONParser.parse(e.getBody()))
                                        .getFields()[0].getMessage().toString();
                            }
                        }
                    } else {
                        if (!StringUtils.isEmpty(errorJSON.getString("error_msg"))) {
                            errorString = errorJSON.getString("error_msg");
                        }
                    }
                }

                AccountCreationActivity.this.onError(errorString);
            } catch (Throwable t) {
                t.printStackTrace();
            }
        }

        protected void onError(Throwable t) {
            AccountCreationActivity.this.onError(t.getLocalizedMessage());
        }

        @Override
        protected void onPostExecute(UsernamePasswordCredential credential) {
            tasks.clear();

            if (credential != null) {
                activate(credential);
                credential.burn();
            }
        }

        @Override
        protected void onPreExecute() {
            Toast.makeText(getActivity(), getString(R.string.creating_account), Toast.LENGTH_LONG).show();
        }

    }));

}

From source file:org.mc4j.ems.impl.jmx.connection.support.providers.proxy.GenericMBeanServerProxy.java

public Object invoke(Object proxy, Method m, Object[] args) throws Throwable {

    //        SwingUtility.eventThreadAlert();
    ///*from w  w  w  .  j  a va  2s .  c  o m*/
    //        ConnectionInfoAction.addHit();

    Class serverClass = this.remoteServer.getClass();
    //org.openide.windows.IOProvider.getDefault().getStdOut().println("Looking at object: " + serverClass.getName());

    Method method = findMethod(m, serverClass);

    //        ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
    try {
        roundTrips++;
        //            Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
        @SuppressWarnings({ "UnnecessaryLocalVariable" })
        Object returnValue = invokeInternal(args, method);
        return returnValue;
    } catch (InvocationTargetException e) {
        failures++;
        if (e.getCause() != null) {
            Throwable t = e.getCause();
            if (t instanceof java.rmi.ConnectException) {
                throw new EmsConnectException(t);
            } else if (t instanceof NoSuchObjectException) {
                // This happens when the server comes back up and the stub is stale.
                // Try to reconnect if this provider supports it (if it told the proxy what the provider was)
                if (provider != null && !reconnecting) {
                    try {
                        log.info("Reestablishing RMI stub to restarted server ["
                                + this.provider.getConnectionSettings().getServerUrl() + "]...");
                        reconnecting = true;
                        provider.connect();
                        // Retry the invocation.
                        @SuppressWarnings({ "UnnecessaryLocalVariable" })
                        Object returnValue = invokeInternal(args, method);
                        return returnValue;
                    } catch (Exception f) {
                        log.warn("Unable to reestablish RMI stub to restarted server ["
                                + this.provider.getConnectionSettings().getServerUrl() + "].", f);
                    } finally {
                        reconnecting = false;
                    }
                }
                // The reconnect failed, throw the original exception
                // If the retry fails, it will throw its own exception
                throw new EmsConnectException(t);
            } else if (t instanceof java.io.IOException) {
                throw new EmsConnectException(t);
            } else if (t instanceof NotSerializableException) {
                throw new EmsUnsupportedTypeException("Value was not serializable " + t.getLocalizedMessage(),
                        t);
            } else {
                throw new EmsConnectException("Connection failure " + t.getLocalizedMessage(), t);
            }
        } else {
            throw e;
        }
    } catch (Exception e) {
        failures++;
        // Log the method.toString() to aid debugging.
        log.error("Failed to invoke method [" + method + "]: " + e);
        //e.printStackTrace();
        throw e;
    } finally {
        //            Thread.currentThread().setContextClassLoader(ctxLoader);
    }
}

From source file:org.opencms.ade.sitemap.CmsVfsSitemapService.java

/**
 * Returns the modified list from the current user.<p>
 * //from  ww  w .j  a v a 2s .co m
 * @return the modified list
 */
private LinkedHashMap<CmsUUID, CmsClientSitemapEntry> getModifiedList() {

    CmsObject cms = getCmsObject();
    CmsUser user = cms.getRequestContext().getCurrentUser();
    Object obj = user.getAdditionalInfo(ADDINFO_ADE_MODIFIED_LIST);
    LinkedHashMap<CmsUUID, CmsClientSitemapEntry> result = new LinkedHashMap<CmsUUID, CmsClientSitemapEntry>();
    if (obj instanceof String) {
        try {
            JSONArray array = new JSONArray((String) obj);
            for (int i = 0; i < array.length(); i++) {
                try {
                    CmsUUID modId = new CmsUUID(array.getString(i));
                    CmsResource res = cms.readResource(modId, CmsResourceFilter.ONLY_VISIBLE);
                    String sitePath = cms.getSitePath(res);
                    CmsJspNavElement navEntry = getNavBuilder().getNavigationForResource(sitePath,
                            CmsResourceFilter.ONLY_VISIBLE);
                    if (navEntry.isInNavigation()) {
                        CmsClientSitemapEntry modEntry = toClientEntry(navEntry, false);
                        result.put(modId, modEntry);
                    }
                } catch (Throwable e) {
                    // should never happen, catches wrong or no longer existing values
                    LOG.warn(e.getLocalizedMessage());
                }
            }
        } catch (Throwable e) {
            // should never happen, catches json parsing
            LOG.warn(e.getLocalizedMessage());
        }
    }
    return result;
}