Top Description Fields Constructors Methods
org.springframework.web.server.handler

public Class ResponseStatusExceptionHandler

extends Object
implements WebExceptionHandler
Class Inheritance
All Implemented Interfaces
org.springframework.web.server.WebExceptionHandler
Imports
org.apache.commons.logging.Log, .LogFactory, reactor.core.publisher.Mono, org.springframework.core.log.LogFormatUtils, org.springframework.http.HttpStatusCode, org.springframework.http.server.reactive.ServerHttpRequest, .ServerHttpResponse, org.springframework.lang.Nullable, org.springframework.web.server.ResponseStatusException, .ServerWebExchange, .WebExceptionHandler

Handle ResponseStatusException by setting the response status.

By default exception stack traces are not shown for successfully resolved exceptions. Use setWarnLogCategory(String) to enable logging with stack traces.

Authors
Rossen Stoyanchev, Sebastien Deleuze
Since
5.0

Field Summary

Modifier and TypeField and Description
private static final Log
private Log

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected int

Returns:

the associated HTTP status code, or -1 if it can't be derived.
determineRawStatusCode
(Throwable
the exception to check
ex
)

Deprecated since 6.0. as of 6.0, in favor of determineStatus(Throwable)
Determine the raw status code for the given exception.
protected HttpStatusCode

Returns:

the associated HTTP status code, or null if it can't be derived
determineStatus
(Throwable
the exception to check
ex
)

Determine the HTTP status for the given exception.

private String
public Mono<Void>
handle(ServerWebExchange
the current exchange
exchange
,
Throwable
the exception to handle
ex
)

Implements org.springframework.web.server.WebExceptionHandler.handle.

Handle the given exception.
public void
setWarnLogCategory(String loggerName)

Set the log category for warn logging.

private boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

loggerback to summary
private static final Log logger
warnLoggerback to summary
private Log warnLogger
Annotations
@Nullable

Constructor Detail

ResponseStatusExceptionHandlerback to summary
public ResponseStatusExceptionHandler()

Method Detail

determineRawStatusCodeback to summary
protected int determineRawStatusCode(Throwable ex)

Deprecated

since 6.0.

as of 6.0, in favor of determineStatus(Throwable)

Determine the raw status code for the given exception.

Parameters
ex:Throwable

the exception to check

Returns:int

the associated HTTP status code, or -1 if it can't be derived.

Annotations
@Deprecated
since:6.0
Since
5.3
determineStatusback to summary
protected HttpStatusCode determineStatus(Throwable ex)

Determine the HTTP status for the given exception.

Parameters
ex:Throwable

the exception to check

Returns:HttpStatusCode

the associated HTTP status code, or null if it can't be derived

Annotations
@Nullable
formatErrorback to summary
private String formatError(Throwable ex, ServerHttpRequest request)
handleback to summary
public Mono<Void> handle(ServerWebExchange exchange, Throwable ex)

Implements org.springframework.web.server.WebExceptionHandler.handle.

Doc from org.springframework.web.server.WebExceptionHandler.handle.

Handle the given exception. A completion signal through the return value indicates error handling is complete while an error signal indicates the exception is still not handled.

Parameters
exchange:ServerWebExchange

the current exchange

ex:Throwable

the exception to handle

Returns:Mono<Void>

Mono<Void> to indicate when exception handling is complete

Annotations
@Override
setWarnLogCategoryback to summary
public void setWarnLogCategory(String loggerName)

Set the log category for warn logging.

Default is no warn logging. Specify this setting to activate warn logging into a specific category.

Since
5.1
See Also
org.apache.commons.logging.LogFactory#getLog(String), java.util.logging.Logger#getLogger(String)
updateResponseback to summary
private boolean updateResponse(ServerHttpResponse response, Throwable ex)
Annotations
@SuppressWarnings:deprecation