Class CodegenException

All Implemented Interfaces:
Serializable

public class CodegenException extends RuntimeException
An exception for any code processing and generation tools. This exception can hold originatingElement() that may be used to provide more information to the user.
See Also:
  • Constructor Details

    • CodegenException

      public CodegenException(String message)
      Constructor with a message.
      Parameters:
      message - descriptive message
    • CodegenException

      public CodegenException(String message, Throwable cause)
      Constructor with a message and a cause.
      Parameters:
      message - descriptive message
      cause - throwable triggering this exception
    • CodegenException

      public CodegenException(String message, Object originatingElement)
      Constructor with a message and an originating element.
      Parameters:
      message - descriptive message
      originatingElement - element that caused this exception
    • CodegenException

      public CodegenException(String message, Throwable cause, Object originatingElement)
      Constructor with a message, cause, and an originating element.
      Parameters:
      message - descriptive message
      cause - throwable triggering this exception
      originatingElement - element that caused this exception
  • Method Details

    • originatingElement

      public Optional<Object> originatingElement()
      Originating element. This may be an annotation processing element, a classpath scanning ClassInfo, or a TypeName. Not type will cause an exception, each environment may check the instance and use it or not.
      Returns:
      originating element of this exception
    • toEvent

      public CodegenEvent toEvent(System.Logger.Level level, String message)
      Create a codegen event to log with CodegenLogger.log(CodegenEvent).
      Parameters:
      level - log level to use
      message - additional message describing the location
      Returns:
      a new codegen event that can be directly logged
    • toEvent

      public CodegenEvent toEvent(System.Logger.Level level)
      Create a codegen event to log with CodegenLogger.log(CodegenEvent).
      Parameters:
      level - log level to use
      Returns:
      a new codegen event that can be directly logged