Example usage for java.lang Throwable toString

List of usage examples for java.lang Throwable toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:com.panoramagl.loaders.PLJSONLoader.java

protected void didError(final Throwable e) {
    mView.getActivity().runOnUiThread(new Runnable() {
        @Override//from   w w  w .ja v a  2 s . c  o m
        public void run() {
            didError(e.toString());
            PLLog.error("PLJSONLoader", e);
        }
    });
}

From source file:com.vuze.plugin.azVPN_PIA.Checker.java

public String portBindingCheck() {
    synchronized (this) {
        if (checkingPortBinding) {
            return lastPortCheckStatus;
        }/*from w w  w  . j a v  a  2  s  .c o m*/
        checkingPortBinding = true;
    }

    CheckerListener[] triggers = listeners.toArray(new CheckerListener[0]);
    for (CheckerListener l : triggers) {
        try {
            l.portCheckStart();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    StringBuilder sReply = new StringBuilder();

    String pathPIAManager = config.getPluginStringParameter(PluginPIA.CONFIG_PIA_MANAGER_DIR);

    File pathPIAManagerData = new File(pathPIAManager, "data");

    try {
        int newStatusID = findBindingAddress(pathPIAManagerData, sReply);

        boolean rpcCalled = false;
        if (newStatusID != STATUS_ID_BAD && vpnIP != null) {
            rpcCalled = callRPCforPort(pathPIAManagerData, vpnIP, sReply);
        }

        if (!rpcCalled) {
            boolean gotPort = checkStatusFileForPort(pathPIAManagerData, sReply);
            if (!gotPort) {
                if (newStatusID != STATUS_ID_BAD) {
                    newStatusID = STATUS_ID_WARN;

                    addReply(sReply, CHAR_WARN, "pia.port.forwarding.get.failed");
                }
            }
        }

        if (newStatusID != -1) {
            currentStatusID = newStatusID;
        }
        String msgID = null;
        if (newStatusID == STATUS_ID_BAD) {
            msgID = "pia.topline.bad";
        } else if (newStatusID == STATUS_ID_OK) {
            msgID = "pia.topline.ok";
        } else if (newStatusID == STATUS_ID_WARN) {
            msgID = "pia.topline.warn";
        }
        if (msgID != null) {
            sReply.insert(0, texts.getLocalisedMessageText(msgID) + "\n");
        }

    } catch (Throwable t) {
        t.printStackTrace();
        PluginPIA.log(t.toString());
    }

    lastPortCheckStatus = sReply.toString();

    triggers = listeners.toArray(new CheckerListener[0]);
    for (CheckerListener l : triggers) {
        try {
            l.portCheckStatusChanged(lastPortCheckStatus);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    synchronized (this) {
        checkingPortBinding = false;
    }
    return lastPortCheckStatus;
}

From source file:dk.netarkivet.harvester.harvesting.distribute.HarvestControllerServer.java

/** Adds error messages from an exception to the status message errors.
 *
 * @param csm The message we're setting messages on.
 * @param crawlException The exception that got thrown from further in,
 * possibly as far in as Heritrix.//from ww w.  j av a2  s.  co  m
 * @param errorMessage Description of errors that happened during upload.
 * @param missingHostsReport If true, no hosts report was found.
 * @param failedFiles List of files that failed to upload.
 */
private void setErrorMessages(CrawlStatusMessage csm, Throwable crawlException, String errorMessage,
        boolean missingHostsReport, int failedFiles) {
    if (crawlException != null) {
        csm.setHarvestErrors(crawlException.toString());
        csm.setHarvestErrorDetails(ExceptionUtils.getStackTrace(crawlException));
    }
    if (errorMessage.length() > 0) {
        String shortDesc = "";
        if (missingHostsReport) {
            shortDesc = "No hosts report found";
        }
        if (failedFiles > 0) {
            if (shortDesc.length() > 0) {
                shortDesc += ", ";
            }
            shortDesc += failedFiles + " files failed to upload";
        }
        csm.setUploadErrors(shortDesc);
        csm.setUploadErrorDetails(errorMessage);
    }
}

From source file:com.mirth.connect.client.ui.SettingsPanelResources.java

public void doReloadResource() {
    final int selectedRow = resourceTable.getSelectedRow();

    if (selectedRow >= 0) {
        if (getFrame().isSaveEnabled()) {
            getFrame().alertWarning(getFrame(), "You must save before reloading any resources.");
            return;
        }// w w w .j a  v a 2s  .  com

        if (!getFrame().alertOption(getFrame(),
                "<html>Libraries associated with this resource will be reloaded.<br/>Any channels / connectors using those libraries will be<br/>affected. Also, a maximum of 1000 files may be loaded into<br/>a directory resource, with additional files being skipped.<br/>Are you sure you wish to continue?</html>")) {
            return;
        }

        final String workingId = getFrame().startWorking("Reloading resource...");
        final String resourceId = ((ResourceProperties) resourceTable.getModel().getValueAt(selectedRow,
                PROPERTIES_COLUMN)).getId();

        SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {

            @Override
            public Void doInBackground() throws ClientException {
                getFrame().mirthClient.reloadResource(resourceId);
                return null;
            }

            @Override
            public void done() {
                try {
                    get();

                    if (resourceTable.getSelectedRow() == selectedRow && currentPropertiesPanel != null) {
                        ResourceProperties properties = (ResourceProperties) resourceTable.getModel()
                                .getValueAt(selectedRow, PROPERTIES_COLUMN);
                        properties.setName(
                                (String) resourceTable.getModel().getValueAt(selectedRow, NAME_COLUMN));
                        properties.setIncludeWithGlobalScripts((Boolean) resourceTable.getModel()
                                .getValueAt(selectedRow, GLOBAL_SCRIPTS_COLUMN));
                        currentPropertiesPanel.fillProperties(properties);
                        currentPropertiesPanel.setProperties(properties);
                    }
                } catch (Throwable t) {
                    if (t instanceof ExecutionException) {
                        t = t.getCause();
                    }
                    getFrame().alertThrowable(getFrame(), t, "Error reloading resource: " + t.toString());
                } finally {
                    getFrame().stopWorking(workingId);
                }
            }
        };

        worker.execute();
    }
}

From source file:com.vmware.photon.controller.nsxclient.apis.LogicalRouterApiTest.java

@Test
public void testDeleteLogicalRouterAsync() throws IOException, InterruptedException {
    setupMocks(null, HttpStatus.SC_OK);/* w w w .j a va 2  s .  c  o m*/
    LogicalRouterApi client = new LogicalRouterApi(restClient);

    final CountDownLatch latch = new CountDownLatch(1);
    client.deleteLogicalRouter("id", new com.google.common.util.concurrent.FutureCallback<Void>() {
        @Override
        public void onSuccess(Void result) {
            latch.countDown();
        }

        @Override
        public void onFailure(Throwable t) {
            fail(t.toString());
            latch.countDown();
        }
    });

    assertThat(latch.await(COUNTDOWNLATCH_AWAIT_TIMEOUT, TimeUnit.SECONDS), is(true));
}

From source file:com.vmware.photon.controller.nsxclient.apis.LogicalRouterApiTest.java

@Test
public void testGetLogicalRouterAsync() throws IOException, InterruptedException {
    final LogicalRouter mockResponse = createLogicalRouter();
    setupMocks(objectMapper.writeValueAsString(mockResponse), HttpStatus.SC_OK);

    LogicalRouterApi client = new LogicalRouterApi(restClient);
    final CountDownLatch latch = new CountDownLatch(1);
    client.getLogicalRouter("id", new com.google.common.util.concurrent.FutureCallback<LogicalRouter>() {
        @Override/* w  w w.ja v a 2 s  . c om*/
        public void onSuccess(LogicalRouter result) {
            assertEquals(result, mockResponse);
            latch.countDown();
        }

        @Override
        public void onFailure(Throwable t) {
            fail(t.toString());
            latch.countDown();
        }
    });

    assertThat(latch.await(COUNTDOWNLATCH_AWAIT_TIMEOUT, TimeUnit.SECONDS), is(true));
}

From source file:com.vmware.photon.controller.nsxclient.apis.LogicalRouterApiTest.java

@Test
public void testCreateLogicalRouterAsync() throws IOException, InterruptedException {
    final LogicalRouter mockResponse = new LogicalRouter();
    mockResponse.setId("id");
    mockResponse.setRouterType(NsxRouter.RouterType.TIER1);
    setupMocks(objectMapper.writeValueAsString(mockResponse), HttpStatus.SC_CREATED);

    LogicalRouterApi client = new LogicalRouterApi(restClient);
    final CountDownLatch latch = new CountDownLatch(1);
    client.createLogicalRouter(new LogicalRouterCreateSpec(),
            new com.google.common.util.concurrent.FutureCallback<LogicalRouter>() {
                @Override/*from w w w . jav a  2s. c o  m*/
                public void onSuccess(LogicalRouter result) {
                    assertEquals(result, mockResponse);
                    latch.countDown();
                }

                @Override
                public void onFailure(Throwable t) {
                    fail(t.toString());
                    latch.countDown();
                }
            });

    assertThat(latch.await(COUNTDOWNLATCH_AWAIT_TIMEOUT, TimeUnit.SECONDS), is(true));
}

From source file:com.esri.gpt.control.rest.ManageDocumentServlet.java

/**
 * Processes the HTTP request.//from   w  w  w. j  a  v a 2s. c  om
 * @param request the HTTP request
 * @param response HTTP response
 * @param context request context
 * @param method the method to executeUpdate GET|PUT|POST|DELETE
 * @throws ServletException if the request cannot be handled
 * @throws IOException if an I/O error occurs while handling the request 
 */
private void execute(HttpServletRequest request, HttpServletResponse response, String method)
        throws ServletException, IOException {

    RequestContext context = null;
    try {
        String msg = "HTTP " + method + ", " + request.getRequestURL().toString();
        if ((request.getQueryString() != null) && (request.getQueryString().length() > 0)) {
            msg += "?" + request.getQueryString();
        }
        getLogger().fine(msg);

        String sEncoding = request.getCharacterEncoding();
        if ((sEncoding == null) || (sEncoding.trim().length() == 0)) {
            request.setCharacterEncoding("UTF-8");
        }
        context = RequestContext.extract(request);

        //redirect to new method for list parameter without any authentication
        if (method.equals("GET") && request.getParameter("list") != null) {
            this.executeGetList(request, response, context);
            return;
        }
        if (method.equals("GET") && request.getParameter("download") != null) {
            this.executeGetPackage(request, response, context);
            return;
        }

        /// estabish the publisher
        StringAttributeMap params = context.getCatalogConfiguration().getParameters();
        String autoAuthenticate = Val.chkStr(params.getValue("BaseServlet.autoAuthenticate"));
        if (!autoAuthenticate.equalsIgnoreCase("false")) {
            Credentials credentials = getCredentials(request);
            if (credentials != null) {
                this.authenticate(context, credentials);
            }
        }
        Publisher publisher = new Publisher(context);

        // executeUpdate the appropriate action
        if (method.equals("GET")) {
            this.executeGet(request, response, context, publisher);
        } else if (method.equals("POST")) {
            this.executePost(request, response, context, publisher);
        } else if (method.equals("PUT")) {
            this.executePut(request, response, context, publisher);
        } else if (method.equals("DELETE")) {
            this.executeDelete(request, response, context, publisher);
        }

    } catch (CredentialsDeniedException e) {
        String sRealm = this.getRealm(context);
        response.setHeader("WWW-Authenticate", "Basic realm=\"" + sRealm + "\"");
        response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
    } catch (NotAuthorizedException e) {
        String sRealm = this.getRealm(context);
        response.setHeader("WWW-Authenticate", "Basic realm=\"" + sRealm + "\"");
        response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
    } catch (ValidationException e) {
        String sMsg = e.toString();
        if (sMsg.contains("XSD violation.")) {
            sMsg = "XSD violation.";
        } else if (sMsg.contains("Invalid metadata document.")) {
            sMsg = "Invalid metadata document.";
        } else {
            sMsg = "Invalid metadata document.";
        }
        String json = Val.chkStr(request.getParameter("errorsAsJson"));
        if (json.length() > 0) {
            json = Val.escapeXmlForBrowser(json);
            FacesContextBroker fcb = new FacesContextBroker(request, response);
            MessageBroker msgBroker = fcb.extractMessageBroker();

            ArrayList<String> validationMessages = new ArrayList<String>();
            e.getValidationErrors().buildMessages(msgBroker, validationMessages, true);

            StringBuilder sb = new StringBuilder();
            sb.append(json).append(" = {\r\n");
            sb.append("message: \"").append(Val.escapeStrForJson(sMsg)).append("\",\r\n");
            sb.append("code: 409,\r\n");
            sb.append("errors: [\r\n");
            for (int i = 0; i < validationMessages.size(); i++) {
                if (i > 0) {
                    sb.append(",\r\n");
                }
                sb.append("\"").append(Val.escapeStrForJson(validationMessages.get(i))).append("\"");
            }
            if (validationMessages.size() > 0) {
                sb.append("\r\n");
            }
            sb.append("]}");

            LOGGER.log(Level.SEVERE, sb.toString());
            response.getWriter().print(sb.toString());
        } else {
            response.sendError(409, sMsg);
        }
    } catch (ServletException e) {
        String sMsg = e.getMessage();
        int nCode = Val.chkInt(sMsg.substring(0, 3), 500);
        sMsg = Val.chkStr(sMsg.substring(4));
        String json = Val.chkStr(request.getParameter("errorsAsJson"));
        if (json.length() > 0) {
            json = Val.escapeXmlForBrowser(json);
            StringBuilder sb = new StringBuilder();
            sb.append(json).append(" = {\r\n");
            sb.append("message: \"").append(Val.escapeStrForJson(sMsg)).append("\",\r\n");
            sb.append("code: ").append(nCode).append(",\r\n");
            sb.append("errors: [\r\n");
            sb.append("\"").append(Val.escapeStrForJson(sMsg)).append("\"");
            sb.append("]}");

            LOGGER.log(Level.SEVERE, sb.toString());
            response.getWriter().print(sb.toString());
        } else {
            response.sendError(nCode, sMsg);
        }
    } catch (Throwable t) {
        String sMsg = t.toString();
        String json = Val.chkStr(request.getParameter("errorsAsJson"));
        if (json.length() > 0) {
            json = Val.escapeXmlForBrowser(json);
            StringBuilder sb = new StringBuilder();
            sb.append(json).append(" = {\r\n");
            sb.append("message: \"").append(Val.escapeStrForJson(sMsg)).append("\",\r\n");
            sb.append("code: ").append(500).append(",\r\n");
            sb.append("errors: [\r\n");
            sb.append("\"").append(Val.escapeStrForJson(sMsg)).append("\"");
            sb.append("]}");

            LOGGER.log(Level.SEVERE, sb.toString());
            response.getWriter().print(sb.toString());
        } else if (sMsg.contains("The document is owned by another user:")) {
            response.sendError(HttpServletResponse.SC_FORBIDDEN, "The document is owned by another user.");
        } else {
            //String sErr = "Exception occured while processing servlet request.";
            //getLogger().log(Level.SEVERE,sErr,t);
            //response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
            //    sMsg + sErr);
        }
    } finally {
        if (context != null)
            context.onExecutionPhaseCompleted();
    }
}

From source file:com.lucidtechnics.blackboard.Blackboard.java

/**
 * Places an object on directly on the Blackboard in the same
 * manner as placeOnBlackboard(Object _object) except that it
 * delays the arrival of that _object until _delay milliseconds has
 * passed.  The object must have a {@link Event} annotation or the Blackboard
 * will eventually throw an Exception./*from w  ww  .  j  a  va2s  .com*/
 * 
 * @param _object the name of the target to be placed on the workspace.
 * @param _delay the time in milliseconds that must pass before
 * event appears on workspace.
 */

public void schedulePlaceOnBlackboard(final Object _event, long _delay) {
    getScheduledBlackboardExecutor().schedule(new Runnable() {
        public void run() {
            try {
                placeOnBlackboard(_event);
            } catch (Throwable t) {
                logger.error("Caught exception: " + t.toString() + " while trying to add event: " + _event
                        + " to the blackboard.", t);
            }
        }
    }, _delay, TimeUnit.MILLISECONDS);
}