Class ConstructorAdviceException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
io.micronaut.context.exceptions.ConstructorAdviceException
All Implemented Interfaces:
Serializable

@Internal public final class ConstructorAdviceException extends RuntimeException
Carries an exception thrown by advice applied around a bean's constructor.

An exception thrown by advice is the user's exception: when advice around a method throws, the caller sees it as it was thrown. Advice around a constructor runs while the container is creating the bean, where any throwable is otherwise wrapped in a BeanInstantiationException. This carrier lets the container tell the two apart, so that an exception thrown by construction advice is rethrown unchanged while an exception thrown by the constructor body keeps being wrapped.

Used for flow control only: it is thrown and caught between ConstructorInterceptorChain#instantiate and the bean creation boundary in DefaultBeanContext, and never reaches user code. It carries no stack trace of its own — the exception the advice threw keeps its own, and it is that one the caller sees.

Since:
5.2.0
Author:
Denis Stepanov
See Also:
  • Constructor Details

    • ConstructorAdviceException

      public ConstructorAdviceException(RuntimeException cause)
      Parameters:
      cause - The exception the advice threw
  • Method Details