Vijeet Vergis
Vijeet Vergis

Reputation: 101

Can HttpServerErrorException return a HttpStatus code other than the ones specified by enumerators in the HttpStatus class?

I would like to handle a particular case of Server error, namely HttpStatus code 599. However, this code is not defined in the HttpStatus class inbuilt in Spring. For all other codes which are defined in HttpStatus class, I used to handle a particular code by the following sample of code:-

if( (e instanceof HttpServerErrorException &&((HttpServerErrorException)e).getStatusCode().equals(HttpStatus.NOT_INPLEMENTED)) )

I want to know if there exists a similar way to handle HttpStatus codes not defined in the HttpStatus class, namely error code 599

Upvotes: 0

Views: 522

Answers (1)

Mạnh Quyết Nguyễn
Mạnh Quyết Nguyễn

Reputation: 18235

When an error with unknown HTTP Status code (the one is not in HttpStatus enum), you can catch UnknownHttpStatusCodeException and access your information from there.

You can read more here SPR-9502

Upvotes: 1

Related Questions