OnApplicationFailed class final

Annotation to mark a method that should run when the application fails to start or refresh.

This is typically used to log errors, notify monitoring systems, or attempt recovery steps.

The only acceptable method signatures are:

  • No-Arg: The method should not accept any arguments.
  • One-Arg: The method should accept a single argument of type Object which will be an exception or optional ConfigurableApplicationContext.
  • Two-Args: The method should accept two arguments of types Object which will be an exception and optional ConfigurableApplicationContext.

Example

class MyApp {
  @OnApplicationFailed()
  void handleFailure() {
    print("Application failed to start!");
  }

  @OnApplicationFailed()
  void handleFailureWithContext(ConfigurableApplicationContext? context) {
    print("Application failed to start!");
  }

  @OnApplicationFailed()
  void handleFailureWithContextAndException(ConfigurableApplicationContext? context, Object exception) {
    print("Application failed to start!");
  }

  @OnApplicationFailed()
  void handleFailureWithException(Object exception) {
    print("Application failed to start!");
  }
}
Annotations
  • @Target.new({TargetKind.method})

Constructors

OnApplicationFailed()
Annotation to mark a method that should run when the application fails to start or refresh.
const

Properties

annotationType Type
Returns the annotation _type of this annotation.
no setter
hashCode int
Returns a hash code consistent with equality definition.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

equals(Object other) bool
Checks whether the given object is logically equivalent to this annotation.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
Returns a string representation of this annotation.
inherited

Operators

operator ==(Object other) bool
Checks if this annotation is equal to another object.
inherited