Package io.levysworks.exceptions
Class RateLimitExceptionMapper
java.lang.Object
io.levysworks.exceptions.RateLimitExceptionMapper
- All Implemented Interfaces:
jakarta.ws.rs.ext.ExceptionMapper<io.smallrye.faulttolerance.api.RateLimitException>
@Provider
public class RateLimitExceptionMapper
extends Object
implements jakarta.ws.rs.ext.ExceptionMapper<io.smallrye.faulttolerance.api.RateLimitException>
Exception mapper for
RateLimitException.
Converts a RateLimitException thrown by the application into an HTTP 429 Too Many Requests
response with a message.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionjakarta.ws.rs.core.ResponsetoResponse(io.smallrye.faulttolerance.api.RateLimitException exception) Converts aRateLimitExceptioninto aResponsewith HTTP status 429 (Too Many Requests).
-
Constructor Details
-
RateLimitExceptionMapper
public RateLimitExceptionMapper()
-
-
Method Details
-
toResponse
public jakarta.ws.rs.core.Response toResponse(io.smallrye.faulttolerance.api.RateLimitException exception) Converts aRateLimitExceptioninto aResponsewith HTTP status 429 (Too Many Requests).- Specified by:
toResponsein interfacejakarta.ws.rs.ext.ExceptionMapper<io.smallrye.faulttolerance.api.RateLimitException>- Parameters:
exception- theRateLimitExceptioninstance that was thrown- Returns:
- a
Responsewith status 429 and a message indicating the rate limit was exceeded
-