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:org.apereo.openlrs.controllers.XAPIExceptionHandlerAdvice.java

@ExceptionHandler(org.springframework.web.util.NestedServletException.class)
public void test(NestedServletException e) {
    Throwable t = e.getCause();
    logger.debug("*************************** " + t.getClass().getName());
}

From source file:de.grobox.blitzmail.AsyncMailTask.java

@Override
protected void onPostExecute(Boolean result) {
    String msg = "";

    // set progress notification to finished
    activity.mBuilder.setProgress(0, 0, false);
    activity.mBuilder.setOngoing(false);

    // set dialog to auto close when clicked
    activity.mBuilder.setAutoCancel(true);

    if (result) {
        // Everything went fine, so delete mail from local storage
        MailStorage.deleteMail(activity, mail.optString("id"));

        // check to see if there should be a success notification
        if (!PreferenceManager.getDefaultSharedPreferences(activity).getBoolean("pref_success_notification",
                true)) {//from   w ww.ja v  a2 s .  c o m
            // don't show success notification
            activity.mNotifyManager.cancel(0);
            return;
        }
        // show success notification
        activity.mBuilder.setSmallIcon(R.drawable.ic_launcher);
        activity.mBuilder.setContentTitle(activity.getString(R.string.sent_mail));
        activity.notifyIntent.putExtra("ContentTitle", activity.getString(R.string.sent_mail));
        msg = mail.optString("subject");
    } else {
        activity.mBuilder.setContentTitle(
                activity.getString(R.string.app_name) + " - " + activity.getString(R.string.error));
        activity.notifyIntent.putExtra("ContentTitle", activity.getString(R.string.error));
        activity.mBuilder.setSmallIcon(android.R.drawable.ic_dialog_alert);

        Log.d("AsyncMailTask", e.getClass().getCanonicalName());

        if (e.getClass().getCanonicalName().equals("javax.mail.AuthenticationFailedException")) {
            msg = activity.getString(R.string.error_auth_failed);
        } else if (e.getClass().getCanonicalName().equals("javax.mail.MessagingException")
                && e.getCause() != null
                && e.getCause().getClass().getCanonicalName().equals("javax.net.ssl.SSLException")
                && e.getCause().getCause().getClass().getCanonicalName()
                        .equals("java.security.cert.CertificateException")) {
            // TODO use MemorizingTrustManager instead, issue #1
            msg = activity.getString(R.string.error_sslcert_invalid);
        } else {
            msg = activity.getString(R.string.error_smtp) + '\n' + e.getMessage();
        }

        // get and show the cause for the exception if it exists
        if (e.getCause() != null) {
            Throwable ecause = e.getCause();
            Log.d("AsyncMailTask", ecause.getClass().getCanonicalName());
            msg += "\nCause: " + ecause.getMessage();
        }
    }

    // Update the notification
    activity.mBuilder.setContentText(msg);
    activity.notifyIntent.putExtra("ContentText", msg);
    activity.mBuilder.setContentIntent(
            PendingIntent.getActivity(activity, 0, activity.notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT));
    activity.mNotifyManager.notify(0, activity.mBuilder.build());
}

From source file:no.kantega.kwashc.server.controller.SiteController.java

private String getHeaderValue(Site site, BindingResult result) {
    String header = "";
    try {// w w  w  .  j  a v  a 2s . c  o  m
        WebTester tester = new WebTester();
        tester.beginAt(site.getAddress());
        tester.getTestingEngine().gotoRootWindow();
        header = tester.getElementAttributeByXPath("/html/head/meta[@name=\"no.kantega.kwashc\"]", "content");
    } catch (Throwable t) {
        result.rejectValue("address", "",
                "Exception (" + t.getClass().getSimpleName() + ") getting the header value: " + t.getMessage());
    }
    return header;
}

From source file:org.thingsplode.agent.monitors.MonitoringExecutor.java

@PostConstruct
public void init() {
    scheduler = Executors.newScheduledThreadPool(schedulerThreadPoolSize, (Runnable r) -> {
        Thread t = new Thread(r, "SCHEDULER");
        t.setDaemon(true);/* ww w  .ja  v a  2s. c om*/
        t.setUncaughtExceptionHandler((Thread t1, Throwable e) -> {
            logger.error(String.format("Uncaught exception on thread %s. Exception %s with message %s.",
                    t1.getName(), e.getClass().getSimpleName(), e.getMessage()), e);
        });
        return t;
    });
    if (autoInitializeSystemMetricProvider) {
        addProvider(new SystemMetricProvider(), 60);
    }
    if (autoInitializeThreadMetricProvider) {
        addProvider(new ThreadMetricProvider(), 300);
    }
    scheduleProviders();
}

From source file:com.garyclayburg.persistence.repository.CustomResponseEntityExceptionHandler.java

@Override
protected ResponseEntity<Object> handleHttpMessageNotReadable(HttpMessageNotReadableException ex,
        HttpHeaders headers, HttpStatus status, WebRequest request) {
    Throwable mostSpecificCause = ex.getMostSpecificCause();
    ErrorMessage errorMessage;//w  w w.java 2  s.  com
    if (mostSpecificCause != null) {
        String exceptionName = mostSpecificCause.getClass().getName();
        String message = mostSpecificCause.getMessage();
        errorMessage = new ErrorMessage(exceptionName, message);
    } else {
        errorMessage = new ErrorMessage(ex.getMessage());
    }
    return new ResponseEntity(errorMessage, headers, status);
}

From source file:com.netflix.genie.web.util.StreamBuffer.java

/**
 * Close this buffer before all data is written due to an error.
 * Reading will return the end of stream marker after the current chunk (if any) has been consumed.
 *
 * @param t the cause for the buffer to be closed.
 *//*from www .j  a va2 s .c  o m*/
public void closeForError(final Throwable t) {
    log.error("Closing buffer due to error: " + t.getClass().getSimpleName() + ": " + t.getMessage());
    this.closeForCompleted();
}

From source file:com.thorpora.module.core.error.ErrorLogger.java

private Level resolveLogLevel(Throwable ex) {
    ExceptionLog logAnnot = AnnotationUtils.findAnnotation(ex.getClass(), ExceptionLog.class);
    if (logAnnot != null) {
        return logAnnot.level();
    }/*from   w  w  w  .j  a  va 2s . co  m*/
    Level logLevel = levelMapping.get(ex.getClass());
    if (logLevel != null) {
        return logLevel;
    }
    return DEFAULT_EXCEPTION_LEVEL;
}

From source file:com.thorpora.module.core.error.ErrorLogger.java

private boolean isStackTraceLogged(Throwable ex) {
    ExceptionLog logAnnot = AnnotationUtils.findAnnotation(ex.getClass(), ExceptionLog.class);
    if (logAnnot != null) {
        return logAnnot.stackTrace();
    }/*w w  w .  j  a v a2 s .  c  o m*/
    Boolean printStack = stackMapping.get(ex.getClass());
    if (printStack != null) {
        return printStack;
    }
    return DEFAULT_STACK_TRACE_PRINTED;
}

From source file:com.ns.retailmgr.controller.exception.RestControllerExceptionHandler.java

protected ResponseEntity<Object> handleRunTimeException(RuntimeException ex, HttpHeaders headers,
        HttpStatus status, WebRequest request) {
    status = HttpStatus.INTERNAL_SERVER_ERROR;
    Throwable mostSpecificCause = ex.getCause();
    RestErrorMessage RestErrorMessage;//from  w w w  .  j  a  v  a  2s  .  c  om
    if (mostSpecificCause != null) {
        String exceptionName = mostSpecificCause.getClass().getName();
        String message = mostSpecificCause.getMessage();
        RestErrorMessage = new RestErrorMessage(exceptionName, message);
    } else {
        RestErrorMessage = new RestErrorMessage(ex.getMessage());
    }
    return new ResponseEntity(RestErrorMessage, headers, status);
}

From source file:com.qwazr.utils.json.JsonException.java

public JsonException(Status status, Exception e) {
    this.error = status == null ? null : status.name();
    this.reason_phrase = status == null ? null : status.getReasonPhrase();
    this.status_code = status == null ? null : status.getStatusCode();
    Throwable cause = e == null ? null : ExceptionUtils.getRootCause(e);
    this.message = cause == null ? null : cause.getMessage();
    this.exception = cause == null ? null : cause.getClass().getName();
    this.stackTraces = cause == null ? null : ExceptionUtils.getStackTraces(cause);
}