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 Details

    • RateLimitExceptionMapper

      public RateLimitExceptionMapper()
  • Method Details

    • toResponse

      public jakarta.ws.rs.core.Response toResponse(io.smallrye.faulttolerance.api.RateLimitException exception)
      Converts a RateLimitException into a Response with HTTP status 429 (Too Many Requests).
      Specified by:
      toResponse in interface jakarta.ws.rs.ext.ExceptionMapper<io.smallrye.faulttolerance.api.RateLimitException>
      Parameters:
      exception - the RateLimitException instance that was thrown
      Returns:
      a Response with status 429 and a message indicating the rate limit was exceeded