Example usage for java.lang Throwable getClass

List of usage examples for java.lang Throwable getClass

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:com.telefonica.euro_iaas.paasmanager.manager.async.impl.ApplicationInstanceAsyncManagerImpl.java

/**
 * Update the task with necessary information when the task is wrong.
 *//*from w  ww .j av a  2 s . com*/
private void updateErrorTask(Task task, String message, Throwable t) {
    TaskError error = new TaskError(message);
    error.setMajorErrorCode(t.getMessage());
    error.setMinorErrorCode(t.getClass().getSimpleName());
    task.setEndTime(new Date());
    task.setStatus(TaskStates.ERROR);
    task.setError(error);
    taskManager.updateTask(task);
    log.info("An error occurs while installing an application release on a" + " environment. See task "
            + task.getHref() + " for more information");
}

From source file:gov.nih.nci.cagrid.portal.portlet.workflow.mvc.NewInstanceFormController.java

@Override
protected void processFormSubmission(ActionRequest request, ActionResponse response, Object command,
        BindException errors) throws Exception {
    String id = PortletRequestUtils.getStringParameter(request, "id", "NaN");
    log.debug("processFormSubmission. action: "
            + PortletRequestUtils.getStringParameter(request, "action", "NaN") + " | id - " + id);
    SubmitWorkflowCommand cmd = (SubmitWorkflowCommand) command;
    log.debug("Command Object: " + cmd.getTheWorkflow());
    try {//from ww w .jav a 2s  .  c o  m
        WorkflowDescription selectedWorkflow = registry.getWorkflow(id);
        log.info("Submitting the selected workflow.. #" + id);
        String tempFilePath = saveWorkflowDefinition(selectedWorkflow);
        EndpointReferenceType epr = workflowService.submitWorkflow(selectedWorkflow.getName(), tempFilePath,
                cmd.getInputValues());
        UUID uuid = UUID.randomUUID();
        log.debug("Will submit UUID : " + uuid.toString());
        eprs.put(uuid.toString(), new WorkflowSubmitted(epr, selectedWorkflow, "Submitted"));
        cmd.setResult("The Workflow was submitted successfully.");
        log.info("The Workflow was submitted successfully.");
    } catch (Throwable e) {
        log.error("Error submitting workflow", e);
        Throwable ex = e.getCause();
        while (ex.getCause() != null) {
            ex = ex.getCause();
        }
        cmd.setResult(e.getClass().getSimpleName() + " submitting workflow: " + e.getMessage());
    }
}

From source file:com.brightcove.com.uploader.verifier.UploadData.java

/**
 * @return true only if all renditions were successfully deleted
 * @throws Throwable//from  ww  w .  jav a 2 s  .  c  om
 */
public boolean deleteDownloadedRenditions(List<Throwable> throwables) throws Throwable {
    boolean anyFailed = false;
    if (rendFiles == null) {
        return true;
    }

    for (String localPath : rendFiles.values()) {
        try {
            anyFailed = ((!new File(localPath).delete()) || anyFailed);
        } catch (Throwable t) {
            mLog.error("Downloaded rendition file " + localPath
                    + " failed to get deleted, because an instance of " + t.getClass() + " was thrown. ", t);
            throwables.add(t);
        }
    }

    return (!anyFailed);
}

From source file:de.decoit.visa.http.ajax.handlers.DiscardModificationsHandler.java

@Override
public void handle(HttpExchange he) throws IOException {
    log.info(he.getRequestURI().toString());

    // Get the URI of the request and extract the query string from it
    QueryString queryParameters = new QueryString(he.getRequestURI());

    // Create StringBuilder for the response
    String response = null;/* w ww  . java  2s.c  o m*/

    // Check if the query parameters are valid for this handler
    if (this.checkQueryParameters(queryParameters)) {
        // Any exception thrown during object creation will cause
        // failure of the AJAX request
        try {
            JSONObject rv = new JSONObject();

            TEBackend.getModificationQueue(queryParameters.get("queueID").get()).discard();

            rv.put("status", AJAXServer.AJAX_SUCCESS);

            response = rv.toString();
        } catch (Throwable ex) {
            TEBackend.logException(ex, log);

            try {
                JSONObject rv = new JSONObject();
                rv.put("status", AJAXServer.AJAX_ERROR_EXCEPTION);
                rv.put("type", ex.getClass().getSimpleName());
                rv.put("message", ex.getMessage());
                response = rv.toString();
            } catch (JSONException e) {
                /* Ignore */
            }
        }

    } else {
        // Missing or malformed query string, set response to error code
        JSONObject rv = new JSONObject();
        try {
            rv.put("status", AJAXServer.AJAX_ERROR_MISSING_ARGS);
        } catch (JSONException exc) {
            /* Ignore */
        }

        response = rv.toString();
    }

    // Send the response
    sendResponse(he, response);
}

From source file:com.jaliansystems.activeMQLite.impl.RepositoryService.java

/**
 * Handles message requests for this object repository.
 * //ww w .ja v a  2  s . com
 * All messages are JMSLiteMessage the protocol of which is explained in Protocol.txt
 */
public void onMessage(Message message) {
    if (message instanceof ActiveMQBytesMessage) {
        try {
            JMSLiteMessage jmsMessage = new JMSLiteMessage((ActiveMQBytesMessage) message);
            byte message_type = (Byte) jmsMessage.read();
            if (message_type == MESSAGE_LOOKUP) {
                String className = (String) jmsMessage.read();
                handleLookup(className, message.getJMSReplyTo(), message.getJMSCorrelationID());
            } else if (message_type == MESSAGE_CALL) {
                JMSLiteMessage rmessage = new JMSLiteMessage();
                rmessage.write(MESSAGE_CALL);
                try {
                    Object returnVal = objectRepository.invoke(jmsMessage, client);
                    rmessage.write(CALL_SUCCESS);
                    rmessage.write(returnVal);
                } catch (Throwable t) {
                    if (log.isDebugEnabled())
                        t.printStackTrace();
                    rmessage.write(CALL_ERROR);
                    rmessage.write(t.getClass().getName());
                    rmessage.write(t.getMessage());
                }
                rmessage.setJMSCorrelationID(message.getJMSCorrelationID());
                rmessage.setJMSDestination(message.getJMSReplyTo());
                responseProducer.send(message.getJMSReplyTo(), rmessage);
            } else if (message_type == MESSAGE_REMOVE) {
                ObjectHandle handle = (ObjectHandle) jmsMessage.read();
                boolean b = objectRepository.removeObject(handle);
                JMSLiteMessage rmessage = new JMSLiteMessage();
                rmessage.write(MESSAGE_REMOVE);
                rmessage.write(b);
                rmessage.setJMSCorrelationID(message.getJMSCorrelationID());
                rmessage.setJMSDestination(message.getJMSReplyTo());
                responseProducer.send(message.getJMSReplyTo(), rmessage);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

From source file:com.timeinc.seleniumite.junit.SimpleSeleniumBuilderTest.java

private Throwable unwrapWebDriverException(Throwable e) {
    Throwable rval = e;//ww  w  .  j  a v  a  2s  .  co m
    // The runtime exception wrapper doesn't help in this case, toss it
    if (RuntimeException.class.isAssignableFrom(e.getClass()) && e.getCause() != null
            && WebDriverException.class.isAssignableFrom(e.getCause().getClass())) {
        // Strip the wrapping RuntimeException in this case
        rval = e.getCause();
    }
    return rval;
}

From source file:com.atypon.wayf.request.ResponseWriter.java

public void buildFailure(RoutingContext routingContext) {
    Throwable failure = routingContext.failure();

    LOG.error("Error processing request", failure);

    // If this is a composite exception from RxJava, get the root failure
    if (CompositeException.class.isAssignableFrom(failure.getClass())) {
        failure = ((CompositeException) failure).getExceptions().get(0);
    }/*w w  w.  ja  v  a2  s. c  om*/

    // Write the stack trace to a stream
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    PrintStream printStream = new PrintStream(outputStream);
    failure.printStackTrace(printStream);

    // Build an error response message
    ErrorResponse errorResponse = new ErrorResponse();
    errorResponse.setMessage(failure.getMessage());

    try {
        errorResponse.setStacktrace(outputStream.toString("utf-8"));
    } catch (UnsupportedEncodingException e) {
        LOG.error("Could not build stack trace", e);
    }

    int statusCode = 500;

    if (ServiceException.class.isAssignableFrom(failure.getClass())) {
        statusCode = ((ServiceException) failure).getStatusCode();
    }

    final int statusCodeToUse = statusCode;

    try {
        errorLoggerFacade.buildAndLogError(statusCode, failure).subscribe(() -> {
        }, (e) -> LOG.error("Could not log error", e));
    } catch (Exception e) {
        LOG.error("Could not log exception", e);
    }

    Completable
            .fromAction(() -> routingContext.response().setStatusCode(statusCodeToUse)
                    .putHeader(CONTENT_TYPE_KEY, CONTENT_TYPE_VALUE).end(Json.encodePrettily(errorResponse)))
            .subscribeOn(Schedulers.io()).subscribe(() -> {
            }, (ex) -> LOG.error("Could not write response to client", ex));
}

From source file:com.nabla.wapp.server.csv.CsvReader.java

@Override
public Status next(T instance) throws FullErrorListException {
    Assert.argumentNotNull(instance);//from   ww  w. ja  va  2  s  . c  o m

    try {
        List<String> values;
        try {
            values = impl.read();
        } catch (IOException e) {
            if (log.isErrorEnabled())
                log.error("error while reading next csv line", e);
            errors.add(getLineNumber(), CommonServerErrors.INTERNAL_ERROR);
            return Status.ERROR;
        }
        if (values == null)
            return Status.EOF;
        if (columns.size() != values.size()) {
            errors.add(getLineNumber(), CommonServerErrors.INVALID_FIELD_COUNT);
            return Status.ERROR;
        }
        for (int c = 0; c < columns.size(); ++c) {
            try {
                columns.get(c).setValue(instance, values.get(c));
            } catch (Throwable e) {
                if (log.isErrorEnabled())
                    log.error("error while reading next csv line", e);
                errors.add(getLineNumber(), columns.get(c).getName(), CommonServerErrors.INVALID_VALUE);
            }
        }
        try {
            if (validate != null)
                validate.invoke(instance, errors);
        } catch (final InvocationTargetException e) {
            final Throwable ee = e.getCause();
            if (log.isErrorEnabled())
                log.error("error while validating next csv line", ee);
            if (ee != null && ee.getClass().equals(FullErrorListException.class))
                throw new FullErrorListException();
            else {
                errors.add(getLineNumber(), CommonServerErrors.INTERNAL_ERROR);
                return Status.ERROR;
            }
        }
        return errors.isEmpty() ? Status.SUCCESS : Status.ERROR;
    } catch (FullErrorListException e) {
        throw e;
    } catch (Throwable e) {
        return Status.ERROR;
    }
}

From source file:de.decoit.visa.http.ajax.handlers.AddInterfaceToComponentHandler.java

@Override
public void handle(HttpExchange he) throws IOException {
    log.info(he.getRequestURI().toString());

    // Get the URI of the request and extract the query string from it
    QueryString queryParameters = new QueryString(he.getRequestURI());

    // Create StringBuilder for the response
    String response = null;/*  w  w w . j a v a  2  s.  c o m*/

    // Check if the query parameters are valid for this handler
    if (this.checkQueryParameters(queryParameters)) {
        // Any exception thrown during object creation will cause
        // failure of the AJAX request
        try {
            JSONObject rv = new JSONObject();

            Interface iface = TEBackend.TOPOLOGY_STORAGE.getComponent(queryParameters.get("compID").get())
                    .getConfig().createInterface(PortOrientation.valueOf(queryParameters.get("ori").get()));

            rv.put("status", AJAXServer.AJAX_SUCCESS);
            rv.put("iface", iface.toJSON());
            rv.put("topology", TEBackend.TOPOLOGY_STORAGE.genTopologyJSON());

            response = rv.toString();
        } catch (Throwable ex) {
            TEBackend.logException(ex, log);

            try {
                JSONObject rv = new JSONObject();
                rv.put("status", AJAXServer.AJAX_ERROR_EXCEPTION);
                rv.put("type", ex.getClass().getSimpleName());
                rv.put("message", ex.getMessage());
                response = rv.toString();
            } catch (JSONException e) {
                /* Ignore */
            }
        }
    } else {
        // Missing or malformed query string, set response to error code
        JSONObject rv = new JSONObject();
        try {
            rv.put("status", AJAXServer.AJAX_ERROR_MISSING_ARGS);
        } catch (JSONException exc) {
            /* Ignore */
        }

        response = rv.toString();
    }

    // Send the response
    sendResponse(he, response);
}

From source file:de.decoit.visa.http.ajax.handlers.IOToolConnectHandler.java

@Override
public void handle(HttpExchange he) throws IOException {
    log.info(he.getRequestURI().toString());

    // Get the URI of the request and extract the query string from it
    QueryString queryParameters = new QueryString(he.getRequestURI());

    // Create String for the response
    String response = null;/*from  w ww  .j  a  va2  s.com*/

    // Check if the query parameters are valid for this handler
    if (this.checkQueryParameters(queryParameters)) {
        // Any exception thrown during object creation will
        // cause failure of the AJAX request
        try {
            TEBackend.createIOConnector(queryParameters.get("host").get(),
                    Integer.parseInt(queryParameters.get("port").get()));

            JSONObject rv = new JSONObject();
            rv.put("status", AJAXServer.AJAX_SUCCESS);
            response = rv.toString();
        } catch (IOToolException iote) {
            JSONObject rv = new JSONObject();
            try {
                rv.put("status", AJAXServer.AJAX_ERROR_IOTOOL_BUSY);
                response = rv.toString();
            } catch (JSONException exc) {
                /* Ignore */
            }
        } catch (Throwable ex) {
            TEBackend.logException(ex, log);

            JSONObject rv = new JSONObject();
            try {
                rv.put("status", AJAXServer.AJAX_ERROR_EXCEPTION);
                rv.put("type", ex.getClass().getSimpleName());
                rv.put("message", ex.getMessage());
            } catch (JSONException exc) {
                /* Ignore */
            }

            response = rv.toString();
        }
    } else {
        JSONObject rv = new JSONObject();
        try {
            // Missing or malformed query string, set response to error code
            rv.put("status", AJAXServer.AJAX_ERROR_MISSING_ARGS);
        } catch (JSONException exc) {
            /* Ignore */
        }

        response = rv.toString();
    }

    // Send the response
    sendResponse(he, response);
}