Package org.springframework.web.server.handler

# Class ResponseStatusExceptionHandler

java.lang.Object
org.springframework.web.server.handler.ResponseStatusExceptionHandler

All Implemented Interfaces:
  `WebExceptionHandler`

public class ResponseStatusExceptionHandler extends Object implements 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.

Since:
  5.0
Author:
  Rossen Stoyanchev, Sebastien Deleuze

## Constructor Summary

Constructors
Constructor
Description
`ResponseStatusExceptionHandler()`

## Method Summary

Modifier and Type
Method
Description
`protected int`
`determineRawStatusCode(Throwable ex)`
Deprecated, for removal: This API element is subject to removal in a future version.
in favor of `determineStatus(Throwable)`, for removal in 7.0
`protected HttpStatusCode`
`determineStatus(Throwable ex)`
Determine the HTTP status for the given exception.
`reactor.core.publisher.Mono<Void>`
`handle(ServerWebExchange exchange, Throwable ex)`
Handle the given exception.
`void`
`setWarnLogCategory(String loggerName)`
Set the log category for warn logging.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### ResponseStatusExceptionHandler

public ResponseStatusExceptionHandler()

## Method Details

### setWarnLogCategory

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:
  - `LogFactory.getLog(String)`
  - `Logger.getLogger(String)`

### handle

public reactor.core.publisher.Mono<Void> handle(ServerWebExchange exchange, Throwable ex)
Description copied from interface: `WebExceptionHandler`
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.

Specified by:
  `handle` in interface `WebExceptionHandler`
Parameters:
  `exchange` - the current exchange
  `ex` - the exception to handle
Returns:
  `Mono<Void>` to indicate when exception handling is complete

### determineStatus

@Nullable protected HttpStatusCode determineStatus(Throwable ex)
Determine the HTTP status for the given exception.

Parameters:
  `ex` - the exception to check
Returns:
  the associated HTTP status code, or `null` if it can't be derived

### determineRawStatusCode

@Deprecated(since="6.0", forRemoval=true) protected int determineRawStatusCode(Throwable ex)
Deprecated, for removal: This API element is subject to removal in a future version.
in favor of `determineStatus(Throwable)`, for removal in 7.0
Determine the raw status code for the given exception.

Parameters:
  `ex` - the exception to check
Returns:
  the associated HTTP status code, or -1 if it can't be derived.
Since:
  5.3