Search in sources :

Example 31 with FailureAnalysis

use of org.springframework.boot.diagnostics.FailureAnalysis in project spring-boot by spring-projects.

the class NoSuchBeanDefinitionFailureAnalyzerTests method failureAnalysisForMissingMapType.

@Test
public void failureAnalysisForMissingMapType() throws Exception {
    FailureAnalysis analysis = analyzeFailure(createFailure(StringMapConfiguration.class));
    assertDescriptionConstructorMissingType(analysis, StringMapHandler.class, 0, String.class);
    assertBeanMethodDisabled(analysis, "did not find property 'spring.string.enabled'", TestPropertyAutoConfiguration.class, "string");
    assertActionMissingType(analysis, String.class);
}
Also used : FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis) Test(org.junit.Test)

Example 32 with FailureAnalysis

use of org.springframework.boot.diagnostics.FailureAnalysis in project microservices by pwillhan.

the class ModelMapConfigurationFailureAnalyzer method analyze.

@Override
protected FailureAnalysis analyze(Throwable rootFailure, ConfigurationException cause) {
    StringBuilder description = new StringBuilder();
    description.append("ModelMapper configuration failed:\n");
    for (ErrorMessage message : cause.getErrorMessages()) {
        description.append(message.getMessage());
    }
    return new FailureAnalysis(description.toString(), "Fix ModelMapper configuration", cause);
}
Also used : FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis) ErrorMessage(org.modelmapper.spi.ErrorMessage)

Example 33 with FailureAnalysis

use of org.springframework.boot.diagnostics.FailureAnalysis in project bucket4j-spring-boot-starter by MarcGiffing.

the class Bucket4JAutoConfigFailureAnalyzer method analyze.

@Override
protected FailureAnalysis analyze(Throwable rootFailure, Bucket4jGeneralException cause) {
    String descriptionMessage = cause.getMessage();
    String actionMessage = cause.getMessage();
    if (cause instanceof JCacheNotFoundException) {
        JCacheNotFoundException ex = (JCacheNotFoundException) cause;
        descriptionMessage = "The cache name name defined in the property is not configured in the caching provider";
        actionMessage = "Cache name: " + ex.getCacheName() + newline + "Please configure your caching provider (ehcache, hazelcast, ...)";
    }
    if (cause instanceof MissingKeyFilterExpressionException) {
        descriptionMessage = "You've set the 'filter-key-type' to 'expression' but didn't set the property 'expression'";
        actionMessage = "Please set the property 'expression' in your configuration file with a valid expression (see Spring Expression Language)" + newline;
    }
    return new FailureAnalysis(descriptionMessage, actionMessage, cause);
}
Also used : MissingKeyFilterExpressionException(com.giffing.bucket4j.spring.boot.starter.exception.MissingKeyFilterExpressionException) JCacheNotFoundException(com.giffing.bucket4j.spring.boot.starter.exception.JCacheNotFoundException) FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis)

Aggregations

FailureAnalysis (org.springframework.boot.diagnostics.FailureAnalysis)33 Test (org.junit.Test)27 JCacheNotFoundException (com.giffing.bucket4j.spring.boot.starter.exception.JCacheNotFoundException)1 MissingKeyFilterExpressionException (com.giffing.bucket4j.spring.boot.starter.exception.MissingKeyFilterExpressionException)1 ArrayList (java.util.ArrayList)1 ErrorMessage (org.modelmapper.spi.ErrorMessage)1 FatalBeanException (org.springframework.beans.FatalBeanException)1 InjectionPoint (org.springframework.beans.factory.InjectionPoint)1 NoUniqueBeanDefinitionException (org.springframework.beans.factory.NoUniqueBeanDefinitionException)1 TestBeanConsumer (org.springframework.boot.diagnostics.analyzer.nounique.TestBeanConsumer)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1 FieldError (org.springframework.validation.FieldError)1 ObjectError (org.springframework.validation.ObjectError)1