org.springframework.boot.web.reactive.error.ErrorAttributes Java Examples

The following examples show how to use org.springframework.boot.web.reactive.error.ErrorAttributes. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ErrorHandlerConfig.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public ErrorWebExceptionHandler errorWebExceptionHandler(ErrorAttributes errorAttributes) {
    JsonExceptionHandler exceptionHandler = new JsonExceptionHandler(
            errorAttributes, 
            this.resourceProperties,
            this.serverProperties.getError(), 
            this.applicationContext);
    exceptionHandler.setViewResolvers(this.viewResolvers);
    exceptionHandler.setMessageWriters(this.serverCodecConfigurer.getWriters());
    exceptionHandler.setMessageReaders(this.serverCodecConfigurer.getReaders());
    return exceptionHandler;
}
 
Example #2
Source File: FwGatewayErrorConfigure.java    From fw-spring-cloud with Apache License 2.0 5 votes vote down vote up
@Bean
    @Order(Ordered.HIGHEST_PRECEDENCE)
    public ErrorWebExceptionHandler errorWebExceptionHandler(ErrorAttributes errorAttributes) {
        FwGatewayExceptionHandler exceptionHandler = new FwGatewayExceptionHandler(
                errorAttributes,
                this.resourceProperties,
                this.serverProperties.getError(),
                this.applicationContext);
        exceptionHandler.setViewResolvers(this.viewResolvers);
        exceptionHandler.setMessageWriters(this.serverCodecConfigurer.getWriters());
        exceptionHandler.setMessageReaders(this.serverCodecConfigurer.getReaders());
        return exceptionHandler;
}
 
Example #3
Source File: ErrorHandlerConfiguration.java    From SpringBlade with Apache License 2.0 5 votes vote down vote up
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public ErrorWebExceptionHandler errorWebExceptionHandler(ErrorAttributes errorAttributes) {
	ErrorExceptionHandler exceptionHandler = new ErrorExceptionHandler(
		errorAttributes,
		this.resourceProperties,
		this.serverProperties.getError(),
		this.applicationContext);
	exceptionHandler.setViewResolvers(this.viewResolvers);
	exceptionHandler.setMessageWriters(this.serverCodecConfigurer.getWriters());
	exceptionHandler.setMessageReaders(this.serverCodecConfigurer.getReaders());
	return exceptionHandler;
}
 
Example #4
Source File: ErrorHandlerConfiguration.java    From codeway_service with GNU General Public License v3.0 5 votes vote down vote up
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public ErrorWebExceptionHandler errorWebExceptionHandler(ErrorAttributes errorAttributes) {
	GlobalExceptionHandler exceptionHandler = new GlobalExceptionHandler(
			errorAttributes,
			this.resourceProperties,
			this.serverProperties.getError(),
			this.applicationContext);
	exceptionHandler.setViewResolvers(this.viewResolvers);
	exceptionHandler.setMessageWriters(this.serverCodecConfigurer.getWriters());
	exceptionHandler.setMessageReaders(this.serverCodecConfigurer.getReaders());
	return exceptionHandler;
}
 
Example #5
Source File: ReactiveWebServerInitializer.java    From spring-fu with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(GenericApplicationContext context) {
	context.registerBean("webServerFactoryCustomizerBeanPostProcessor", WebServerFactoryCustomizerBeanPostProcessor.class, WebServerFactoryCustomizerBeanPostProcessor::new);

	context.registerBean(ReactiveWebServerFactoryCustomizer.class, () -> new ReactiveWebServerFactoryCustomizer(this.serverProperties));
	context.registerBean(ConfigurableReactiveWebServerFactory.class, () -> serverFactory);
	//noinspection deprecation
	context.registerBean(ErrorAttributes.class, () -> new DefaultErrorAttributes(serverProperties.getError().isIncludeException()));
	context.registerBean(ErrorWebExceptionHandler.class,  () -> {
		ErrorWebFluxAutoConfiguration errorConfiguration = new ErrorWebFluxAutoConfiguration(this.serverProperties);
		return errorConfiguration.errorWebExceptionHandler(context.getBean(ErrorAttributes.class), this.resourceProperties, context.getBeanProvider(ViewResolver.class), context.getBean(SERVER_CODEC_CONFIGURER_BEAN_NAME, ServerCodecConfigurer.class), context);
	});
	context.registerBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class, () -> new EnableWebFluxConfigurationWrapper(context, webFluxProperties));
	context.registerBean(LOCALE_CONTEXT_RESOLVER_BEAN_NAME, LocaleContextResolver.class, () -> context.getBean(EnableWebFluxConfigurationWrapper.class).localeContextResolver());
	context.registerBean("responseStatusExceptionHandler", WebExceptionHandler.class, () -> context.getBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class).responseStatusExceptionHandler());

	context.registerBean(RouterFunctionMapping.class, () -> context.getBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class).routerFunctionMapping(context.getBean(SERVER_CODEC_CONFIGURER_BEAN_NAME, ServerCodecConfigurer.class)));
	context.registerBean(SERVER_CODEC_CONFIGURER_BEAN_NAME, ServerCodecConfigurer.class, () -> context.getBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class).serverCodecConfigurer());
	context.registerBean("webFluxAdapterRegistry", ReactiveAdapterRegistry.class, () -> context.getBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class).webFluxAdapterRegistry());
	context.registerBean("handlerFunctionAdapter", HandlerFunctionAdapter.class, () -> context.getBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class).handlerFunctionAdapter());
	context.registerBean("webFluxContentTypeResolver", RequestedContentTypeResolver.class, () -> context.getBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class).webFluxContentTypeResolver());
	context.registerBean("webFluxConversionService", FormattingConversionService.class, () -> context.getBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class).webFluxConversionService());
	context.registerBean("serverResponseResultHandler", ServerResponseResultHandler.class, () -> context.getBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class).serverResponseResultHandler(context.getBean(SERVER_CODEC_CONFIGURER_BEAN_NAME, ServerCodecConfigurer.class)));
	context.registerBean("simpleHandlerAdapter", SimpleHandlerAdapter.class, () -> context.getBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class).simpleHandlerAdapter());
	context.registerBean("viewResolutionResultHandler", ViewResolutionResultHandler.class, () -> context.getBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class).viewResolutionResultHandler(context.getBean("webFluxAdapterRegistry", ReactiveAdapterRegistry.class), context.getBean("webFluxContentTypeResolver", RequestedContentTypeResolver.class)));
	context.registerBean("webFluxValidator", Validator.class, () -> context.getBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class).webFluxValidator());
	context.registerBean(HttpHandler.class, () -> applicationContext(context).build());
	context.registerBean(WEB_HANDLER_BEAN_NAME, DispatcherHandler.class, (Supplier<DispatcherHandler>) DispatcherHandler::new);
	context.registerBean(WebFluxConfig.class, () -> new WebFluxConfig(resourceProperties, webFluxProperties, context, context.getBeanProvider(HandlerMethodArgumentResolver.class), context.getBeanProvider(CodecCustomizer.class),
		context.getBeanProvider(ResourceHandlerRegistrationCustomizer.class), context.getBeanProvider(ViewResolver.class)));
}
 
Example #6
Source File: ExceptionAutoConfiguration.java    From JetfireCloud with Apache License 2.0 5 votes vote down vote up
@Bean
public ErrorWebExceptionHandler errorWebExceptionHandler(ErrorAttributes errorAttributes) {
    DefaultErrorWebExceptionHandler exceptionHandler = new CustomErrorWebExceptionHandler(
            errorAttributes, this.resourceProperties,
            this.serverProperties.getError(), this.applicationContext);
    exceptionHandler.setViewResolvers(this.viewResolvers);
    exceptionHandler.setMessageWriters(this.serverCodecConfigurer.getWriters());
    exceptionHandler.setMessageReaders(this.serverCodecConfigurer.getReaders());
    return exceptionHandler;
}
 
Example #7
Source File: CustomErrorWebFluxAutoConfiguration.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public ErrorWebExceptionHandler errorWebExceptionHandler(ErrorAttributes errorAttributes) {
    JsonErrorWebExceptionHandler exceptionHandler = new JsonErrorWebExceptionHandler(
            errorAttributes,
            this.resourceProperties,
            this.serverProperties.getError(),
            this.applicationContext);
    exceptionHandler.setViewResolvers(this.viewResolvers);
    exceptionHandler.setMessageWriters(this.serverCodecConfigurer.getWriters());
    exceptionHandler.setMessageReaders(this.serverCodecConfigurer.getReaders());
    return exceptionHandler;
}
 
Example #8
Source File: ErrorHandlerConfiguration.java    From sophia_scaffolding with Apache License 2.0 5 votes vote down vote up
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public ErrorWebExceptionHandler errorWebExceptionHandler(ErrorAttributes errorAttributes) {
    JsonExceptionHandler exceptionHandler = new JsonExceptionHandler(
            errorAttributes,
            this.resourceProperties,
            this.serverProperties.getError(),
            this.applicationContext);
    exceptionHandler.setViewResolvers(this.viewResolvers);
    exceptionHandler.setMessageWriters(this.serverCodecConfigurer.getWriters());
    exceptionHandler.setMessageReaders(this.serverCodecConfigurer.getReaders());
    return exceptionHandler;
}
 
Example #9
Source File: ErrorHandlerConfiguration.java    From soul with Apache License 2.0 5 votes vote down vote up
/**
 * Error web exception handler error web exception handler.
 *
 * @param errorAttributes the error attributes
 * @return the error web exception handler
 */
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public ErrorWebExceptionHandler errorWebExceptionHandler(final ErrorAttributes errorAttributes) {
    GlobalErrorHandler exceptionHandler = new GlobalErrorHandler(
            errorAttributes,
            this.resourceProperties,
            this.serverProperties.getError(),
            this.applicationContext);
    exceptionHandler.setViewResolvers(this.viewResolvers);
    exceptionHandler.setMessageWriters(this.serverCodecConfigurer.getWriters());
    exceptionHandler.setMessageReaders(this.serverCodecConfigurer.getReaders());
    return exceptionHandler;
}
 
Example #10
Source File: FebsGatewayErrorConfigure.java    From FEBS-Cloud with Apache License 2.0 5 votes vote down vote up
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public ErrorWebExceptionHandler errorWebExceptionHandler(ErrorAttributes errorAttributes) {
    FebsGatewayExceptionHandler exceptionHandler = new FebsGatewayExceptionHandler(
            errorAttributes,
            this.resourceProperties,
            this.serverProperties.getError(),
            this.applicationContext);
    exceptionHandler.setViewResolvers(this.viewResolvers);
    exceptionHandler.setMessageWriters(this.serverCodecConfigurer.getWriters());
    exceptionHandler.setMessageReaders(this.serverCodecConfigurer.getReaders());
    return exceptionHandler;
}
 
Example #11
Source File: ErrorHandler.java    From sophia_scaffolding with Apache License 2.0 5 votes vote down vote up
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public ErrorWebExceptionHandler errorWebExceptionHandler(ErrorAttributes errorAttributes) {
    JsonExceptionHandler exceptionHandler = new JsonExceptionHandler(
            errorAttributes,
            this.resourceProperties,
            this.serverProperties.getError(),
            this.applicationContext);
    exceptionHandler.setViewResolvers(this.viewResolvers);
    exceptionHandler.setMessageWriters(this.serverCodecConfigurer.getWriters());
    exceptionHandler.setMessageReaders(this.serverCodecConfigurer.getReaders());
    return exceptionHandler;
}
 
Example #12
Source File: ExceptionAutoConfiguration.java    From SpringCloud with Apache License 2.0 5 votes vote down vote up
@Bean
public ErrorWebExceptionHandler errorWebExceptionHandler(ErrorAttributes errorAttributes) {
    DefaultErrorWebExceptionHandler exceptionHandler = new CustomErrorWebExceptionHandler(
            errorAttributes, this.resourceProperties,
            this.serverProperties.getError(), this.applicationContext);
    exceptionHandler.setViewResolvers(this.viewResolvers);
    exceptionHandler.setMessageWriters(this.serverCodecConfigurer.getWriters());
    exceptionHandler.setMessageReaders(this.serverCodecConfigurer.getReaders());
    return exceptionHandler;
}
 
Example #13
Source File: GlobalErrorWebExceptionHandler.java    From light-security with Apache License 2.0 5 votes vote down vote up
@Override
protected RouterFunction<ServerResponse> getRoutingFunction(
        ErrorAttributes errorAttributes) {

    return RouterFunctions.route(
            RequestPredicates.all(), this::renderErrorResponse);
}
 
Example #14
Source File: ErrorHandler.java    From sophia_scaffolding with Apache License 2.0 5 votes vote down vote up
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public ErrorWebExceptionHandler errorWebExceptionHandler(ErrorAttributes errorAttributes) {
    JsonExceptionHandler exceptionHandler = new JsonExceptionHandler(
            errorAttributes,
            this.resourceProperties,
            this.serverProperties.getError(),
            this.applicationContext);
    exceptionHandler.setViewResolvers(this.viewResolvers);
    exceptionHandler.setMessageWriters(this.serverCodecConfigurer.getWriters());
    exceptionHandler.setMessageReaders(this.serverCodecConfigurer.getReaders());
    return exceptionHandler;
}
 
Example #15
Source File: GlobalErrorWebFluxConfiguration.java    From light-security with Apache License 2.0 5 votes vote down vote up
@Bean
@Order(-2)
public ErrorWebExceptionHandler errorWebExceptionHandler(ErrorAttributes errorAttributes) {
    GlobalErrorWebExceptionHandler exceptionHandler = new GlobalErrorWebExceptionHandler(
            errorAttributes,
            this.resourceProperties,
            this.applicationContext
    );

    exceptionHandler.setViewResolvers(this.viewResolvers);
    exceptionHandler.setMessageWriters(this.serverCodecConfigurer.getWriters());
    exceptionHandler.setMessageReaders(this.serverCodecConfigurer.getReaders());
    return exceptionHandler;
}
 
Example #16
Source File: FunctionEndpointInitializer.java    From spring-cloud-function with Apache License 2.0 5 votes vote down vote up
private DefaultErrorWebExceptionHandler errorHandler(GenericApplicationContext context) {
	context.registerBean(ErrorAttributes.class, () -> new DefaultErrorAttributes());
	context.registerBean(ErrorProperties.class, () -> new ErrorProperties());
	context.registerBean(ResourceProperties.class, () -> new ResourceProperties());
	DefaultErrorWebExceptionHandler handler = new DefaultErrorWebExceptionHandler(
			context.getBean(ErrorAttributes.class), context.getBean(ResourceProperties.class),
			context.getBean(ErrorProperties.class), context);
	ServerCodecConfigurer codecs = ServerCodecConfigurer.create();
	handler.setMessageWriters(codecs.getWriters());
	handler.setMessageReaders(codecs.getReaders());
	return handler;
}
 
Example #17
Source File: WebExceptionConfig.java    From influx-proxy with Apache License 2.0 5 votes vote down vote up
@Bean
public ErrorWebExceptionHandler errorWebExceptionHandler(
        ErrorAttributes errorAttributes) {
    InfluxErrorWebExceptionHandler exceptionHandler = new InfluxErrorWebExceptionHandler(
            errorAttributes, this.resourceProperties,
            this.serverProperties.getError(), this.applicationContext);
    exceptionHandler.setViewResolvers(this.viewResolvers);
    exceptionHandler.setMessageWriters(this.serverCodecConfigurer.getWriters());
    exceptionHandler.setMessageReaders(this.serverCodecConfigurer.getReaders());
    return exceptionHandler;
}
 
Example #18
Source File: ErrorHandlerConfiguration.java    From codeway_service with GNU General Public License v3.0 5 votes vote down vote up
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public ErrorWebExceptionHandler errorWebExceptionHandler(ErrorAttributes errorAttributes) {
	GlobalExceptionHandler exceptionHandler = new GlobalExceptionHandler(
			errorAttributes,
			this.resourceProperties,
			this.serverProperties.getError(),
			this.applicationContext);
	exceptionHandler.setViewResolvers(this.viewResolvers);
	exceptionHandler.setMessageWriters(this.serverCodecConfigurer.getWriters());
	exceptionHandler.setMessageReaders(this.serverCodecConfigurer.getReaders());
	return exceptionHandler;
}
 
Example #19
Source File: ErrorHandlerConfiguration.java    From momo-cloud-permission with Apache License 2.0 5 votes vote down vote up
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public ErrorWebExceptionHandler errorWebExceptionHandler(ErrorAttributes errorAttributes) {
    JsonExceptionHandler exceptionHandler = new JsonExceptionHandler(
            errorAttributes,
            this.resourceProperties,
            this.serverProperties.getError(),
            this.applicationContext);
    exceptionHandler.setViewResolvers(this.viewResolvers);
    exceptionHandler.setMessageWriters(this.serverCodecConfigurer.getWriters());
    exceptionHandler.setMessageReaders(this.serverCodecConfigurer.getReaders());
    return exceptionHandler;
}
 
Example #20
Source File: JsonExceptionHandler.java    From sophia_scaffolding with Apache License 2.0 4 votes vote down vote up
public JsonExceptionHandler(ErrorAttributes errorAttributes, ResourceProperties resourceProperties,
                            ErrorProperties errorProperties, ApplicationContext applicationContext) {
    super(errorAttributes, resourceProperties, errorProperties, applicationContext);
}
 
Example #21
Source File: GlobalErrorHandler.java    From soul with Apache License 2.0 4 votes vote down vote up
@Override
protected RouterFunction<ServerResponse> getRoutingFunction(final ErrorAttributes errorAttributes) {
    return RouterFunctions.route(RequestPredicates.all(), this::renderErrorResponse);
}
 
Example #22
Source File: JsonExceptionHandler.java    From sophia_scaffolding with Apache License 2.0 4 votes vote down vote up
/**
 * 指定响应处理方法为JSON处理的方法
 * @param errorAttributes
 */
@Override
protected RouterFunction<ServerResponse> getRoutingFunction(ErrorAttributes errorAttributes) {
    return RouterFunctions.route(RequestPredicates.all(), this::renderErrorResponse);
}
 
Example #23
Source File: JsonExceptionHandler.java    From sophia_scaffolding with Apache License 2.0 4 votes vote down vote up
/**
 * 指定响应处理方法为JSON处理的方法
 * @param errorAttributes
 */
@Override
protected RouterFunction<ServerResponse> getRoutingFunction(ErrorAttributes errorAttributes) {
    return RouterFunctions.route(RequestPredicates.all(), this::renderErrorResponse);
}
 
Example #24
Source File: GlobalErrorWebExceptionHandler.java    From tutorials with MIT License 4 votes vote down vote up
@Override
protected RouterFunction<ServerResponse> getRoutingFunction(final ErrorAttributes errorAttributes) {
    return RouterFunctions.route(RequestPredicates.all(), this::renderErrorResponse);
}
 
Example #25
Source File: GlobalExceptionHandler.java    From codeway_service with GNU General Public License v3.0 4 votes vote down vote up
public GlobalExceptionHandler(ErrorAttributes errorAttributes, ResourceProperties resourceProperties,
                              ErrorProperties errorProperties, ApplicationContext applicationContext) {
	super(errorAttributes, resourceProperties, errorProperties, applicationContext);
}
 
Example #26
Source File: GlobalExceptionHandler.java    From codeway_service with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 指定响应处理方法为JSON处理的方法
 * @param errorAttributes
 */
@Override
protected RouterFunction<ServerResponse> getRoutingFunction(ErrorAttributes errorAttributes) {
	return RouterFunctions.route(RequestPredicates.all(), this::renderErrorResponse);
}
 
Example #27
Source File: CustomErrorWebExceptionHandler.java    From JetfireCloud with Apache License 2.0 4 votes vote down vote up
@Override
protected RouterFunction<ServerResponse> getRoutingFunction(ErrorAttributes errorAttributes) {
    return RouterFunctions.route(RequestPredicates.all(), this::renderErrorResponse);
}
 
Example #28
Source File: GlobalErrorWebExceptionHandler.java    From springboot-learning-example with Apache License 2.0 4 votes vote down vote up
@Override
protected RouterFunction<ServerResponse> getRoutingFunction(final ErrorAttributes errorAttributes) {
    return RouterFunctions.route(RequestPredicates.all(), this::renderErrorResponse);
}
 
Example #29
Source File: GlobalErrorWebExceptionHandler.java    From microservice-integration with MIT License 4 votes vote down vote up
@Override
protected RouterFunction<ServerResponse> getRoutingFunction(final ErrorAttributes errorAttributes) {
    return RouterFunctions.route(RequestPredicates.all(), this::renderErrorResponse);
}
 
Example #30
Source File: CustomErrorWebExceptionHandler.java    From SpringCloud with Apache License 2.0 4 votes vote down vote up
@Override
protected RouterFunction<ServerResponse> getRoutingFunction(ErrorAttributes errorAttributes) {
    return RouterFunctions.route(RequestPredicates.all(), this::renderErrorResponse);
}