Package org.springframework.core.io.support

# Interface SpringFactoriesLoader.FailureHandler

Enclosing class:
  SpringFactoriesLoader

Functional Interface:
  This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public static interface SpringFactoriesLoader.FailureHandler
Strategy for handling a failure that occurs when instantiating a factory.

Since:
  6.0
See Also:
  - `throwing()`
  - `logging(Log)`

## Method Summary

Modifier and Type
Method
Description
`void`
`handleFailure(Class<?> factoryType, String factoryImplementationName, Throwable failure)`
Handle the `failure` that occurred when instantiating the `factoryImplementationName` that was expected to be of the given `factoryType`.
`static SpringFactoriesLoader.FailureHandler`
`handleMessage(BiConsumer<Supplier<String>,Throwable> messageHandler)`
Create a new `SpringFactoriesLoader.FailureHandler` that handles errors using a standard formatted message.
`static SpringFactoriesLoader.FailureHandler`
`logging(org.apache.commons.logging.Log logger)`
Create a new `SpringFactoriesLoader.FailureHandler` that handles errors by logging trace messages.
`static SpringFactoriesLoader.FailureHandler`
`throwing()`
Create a new `SpringFactoriesLoader.FailureHandler` that handles errors by throwing an `IllegalArgumentException`.
`static SpringFactoriesLoader.FailureHandler`
`throwing(BiFunction<String,Throwable,? extends RuntimeException> exceptionFactory)`
Create a new `SpringFactoriesLoader.FailureHandler` that handles errors by throwing an exception.

## Method Details

### handleFailure

void handleFailure(Class<?> factoryType, String factoryImplementationName, Throwable failure)
Handle the `failure` that occurred when instantiating the `factoryImplementationName` that was expected to be of the given `factoryType`.

Parameters:
  `factoryType` - the type of the factory
  `factoryImplementationName` - the name of the factory implementation
  `failure` - the failure that occurred
See Also:
  - `throwing()`
  - `logging(org.apache.commons.logging.Log)`

### throwing

static SpringFactoriesLoader.FailureHandler throwing()
Create a new `SpringFactoriesLoader.FailureHandler` that handles errors by throwing an `IllegalArgumentException`.

Returns:
  a new `SpringFactoriesLoader.FailureHandler` instance
See Also:
  - `throwing(BiFunction)`

### throwing

static SpringFactoriesLoader.FailureHandler throwing(BiFunction<String,Throwable,? extends RuntimeException> exceptionFactory)
Create a new `SpringFactoriesLoader.FailureHandler` that handles errors by throwing an exception.

Parameters:
  `exceptionFactory` - factory used to create the exception
Returns:
  a new `SpringFactoriesLoader.FailureHandler` instance

### logging

static SpringFactoriesLoader.FailureHandler logging(org.apache.commons.logging.Log logger)
Create a new `SpringFactoriesLoader.FailureHandler` that handles errors by logging trace messages.

Parameters:
  `logger` - the logger used to log messages
Returns:
  a new `SpringFactoriesLoader.FailureHandler` instance

### handleMessage

static SpringFactoriesLoader.FailureHandler handleMessage(BiConsumer<Supplier<String>,Throwable> messageHandler)
Create a new `SpringFactoriesLoader.FailureHandler` that handles errors using a standard formatted message.

Parameters:
  `messageHandler` - the message handler used to handle the problem
Returns:
  a new `SpringFactoriesLoader.FailureHandler` instance