Example usage for java.lang.annotation AnnotationTypeMismatchException getStackTrace

List of usage examples for java.lang.annotation AnnotationTypeMismatchException getStackTrace

Introduction

In this page you can find the example usage for java.lang.annotation AnnotationTypeMismatchException getStackTrace.

Prototype

public StackTraceElement[] getStackTrace() 

Source Link

Document

Provides programmatic access to the stack trace information printed by #printStackTrace() .

Usage

From source file:cop.raml.processor.RestProcessor.java

/**
 * This method is responsible for calling {@link #processMethod(RestApi, ExecutableElement)} and catch all exceptions.
 *
 * @param api           rest api//ww w.j  a va  2 s .  co  m
 * @param methodElement method element
 */
private void processMethodWithCatchException(@NotNull RestApi api, @NotNull ExecutableElement methodElement) {
    try {
        processMethod(api, methodElement);
    } catch (AnnotationTypeMismatchException e) {
        String className = methodElement.getEnclosingElement().getSimpleName().toString();
        String message = String.format(
                "Unable to read annotation parameter '%s' for %s.%s(). Try to use simple inline String.",
                e.element().getName(), className, methodElement.getSimpleName());
        AnnotationMirror annotationMirror = getAnnotationMirror(methodElement,
                e.element().getDeclaringClass().getName());
        AnnotationValue annotationValue = getAnnotationValue(annotationMirror, e.element().getName() + "()");
        ThreadLocalContext.getMessager().printMessage(WARNING, message, methodElement, annotationMirror,
                annotationValue);
    } catch (Exception e) {
        String message = String.format("%s: %s", e.getClass().getName(), e.getStackTrace()[0]);
        ThreadLocalContext.getMessager().printMessage(WARNING, message, methodElement);
    }
}