Class TooManyRequests
- All Implemented Interfaces:
Serializable,HttpMessage,HttpResponse
- Direct Known Subclasses:
TooManyRequests.Unmodifiable
The user has sent too many requests in a given amount of time.
Intended for use with rate-limiting schemes.
See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classUnmodifiable point-in-time snapshot of the enclosingTooManyRequestsexception. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final TooManyRequestsReusable unmodifiable instancestatic final StringReason phrasestatic final intHTTP status code -
Constructor Summary
ConstructorsModifierConstructorDescriptionConstructor.TooManyRequests(String msg, Object... args) Constructor.TooManyRequests(Throwable cause) Constructor.TooManyRequests(Throwable cause, String msg, Object... args) Constructor.TooManyRequests(HttpResponse response) Constructor.protectedTooManyRequests(TooManyRequests copyFrom) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Creates a modifiable copy of this bean.setContent(String value) Sets the body on this response.setContent(HttpEntity value) Sets the body on this response.setHeader2(String name, Object value) Sets a header on this response.setHeaders(List<Header> values) Sets the specified headers on this response.setHeaders(HeaderList value) Sets the specified headers on this response.setHeaders2(Header... values) Sets multiple headers on this response.setLocale2(Locale value) Sets the locale used to retrieve reason phrases.setMessage(String message, Object... args) Sets the detail message on this exception.Sets the protocol version on the status line.setReasonPhrase2(String value) Sets the reason phrase on the status line.Sets the reason phrase catalog used to retrieve reason phrases.setStatusCode2(int code) Same asBasicHttpException.setStatusCode(int)but returns this object.setStatusLine(BasicStatusLine value) Sets the protocol version on the status line.Returns an unmodifiable snapshot of this bean.Methods inherited from class org.apache.juneau.http.classic.response.BasicHttpException
addHeader, addHeader, assertStatusCode, containsHeader, equals, freeze, getAllHeaders, getEntity, getFirstHeader, getFullStackMessage, getHeaders, getHeaders, getLastHeader, getLocale, getMessage, getParams, getProtocolVersion, getRootCause, getStatusLine, hashCode, headerIterator, headerIterator, isUnmodifiable, modify, removeHeader, removeHeaders, setEntity, setHeader, setHeader, setHeaders, setLocale, setParams, setReasonPhrase, setStatusCode, setStatusLine, setStatusLine, setStatusLine, toStringMethods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
Field Details
-
STATUS_CODE
HTTP status code- See Also:
-
REASON_PHRASE
Reason phrase- See Also:
-
INSTANCE
Reusable unmodifiable instance
-
-
Constructor Details
-
TooManyRequests
public TooManyRequests()Constructor. -
TooManyRequests
Constructor.This is the constructor used when parsing an HTTP response.
- Parameters:
response- The HTTP response to copy from. Must not benull .- Throws:
IllegalArgumentException- If HTTP response status code does not match what was expected.
-
TooManyRequests
Constructor.- Parameters:
msg- The message. Can benull , in which case the reason phrase is used as the message.args- OptionalString.format-style arguments in the message.
-
TooManyRequests
Constructor.- Parameters:
cause- The cause. Can benull , in which case the reason phrase is used as the message and no cause is chained.
-
TooManyRequests
Constructor.- Parameters:
cause- The caused-by exception. Can benull (no cause is chained).msg- The message. Can benull , in which case the cause's message is used, or the reason phrase if the cause is alsonull or has no message.args- The message arguments.
-
TooManyRequests
Copy constructor.- Parameters:
copyFrom- The bean to copy. Must not benull .
-
-
Method Details
-
copy
Creates a modifiable copy of this bean.- Returns:
- A new modifiable bean.
-
setContent
Description copied from class:BasicHttpExceptionSets the body on this response.- Overrides:
setContentin classBasicHttpException- Parameters:
value- The body on this response. Can benull to unset the property.- Returns:
- This object.
-
setContent
Description copied from class:BasicHttpExceptionSets the body on this response.- Overrides:
setContentin classBasicHttpException- Parameters:
value- The body on this response. Can benull (treated as an empty string).- Returns:
- This object.
-
setHeader2
Description copied from class:BasicHttpExceptionSets a header on this response.- Overrides:
setHeader2in classBasicHttpException- Parameters:
name- The header name.value- The header value.- Returns:
- This object.
-
setHeaders
Description copied from class:BasicHttpExceptionSets the specified headers on this response.- Overrides:
setHeadersin classBasicHttpException- Parameters:
value- The new value. Must not benull .- Returns:
- This object.
-
setHeaders
Description copied from class:BasicHttpExceptionSets the specified headers on this response.- Overrides:
setHeadersin classBasicHttpException- Parameters:
values- The headers to set.null values are ignored.- Returns:
- This object.
-
setHeaders2
Description copied from class:BasicHttpExceptionSets multiple headers on this response.- Overrides:
setHeaders2in classBasicHttpException- Parameters:
values- The headers to add.- Returns:
- This object.
-
setLocale2
Description copied from class:BasicHttpExceptionSets the locale used to retrieve reason phrases.If not specified, uses
Locale.getDefault().- Overrides:
setLocale2in classBasicHttpException- Parameters:
value- The new value. Can benull . The effect is implementation-dependent, depending on the configuredReasonPhraseCatalog(e.g. ignored byEnglishReasonPhraseCatalog).- Returns:
- This object.
-
setMessage
Description copied from class:BasicRuntimeExceptionSets the detail message on this exception.- Overrides:
setMessagein classBasicHttpException- Parameters:
message- The message.args- The message args.- Returns:
- This object.
-
setProtocolVersion
Description copied from class:BasicHttpExceptionSets the protocol version on the status line.If not specified,
"HTTP/1.1" will be used.- Overrides:
setProtocolVersionin classBasicHttpException- Parameters:
value- The new value. Can benull , in which case the default protocol version is cleared andBasicStatusLine.getProtocolVersion()returnsnull .- Returns:
- This object.
-
setReasonPhrase2
Description copied from class:BasicHttpExceptionSets the reason phrase on the status line.If not specified, the reason phrase will be retrieved from the reason phrase catalog using the locale on this builder.
- Overrides:
setReasonPhrase2in classBasicHttpException- Parameters:
value- The new value. Can benull to fall back to the reason phrase catalog.- Returns:
- This object.
-
setReasonPhraseCatalog
Description copied from class:BasicHttpExceptionSets the reason phrase catalog used to retrieve reason phrases.If not specified, uses
EnglishReasonPhraseCatalog.- Overrides:
setReasonPhraseCatalogin classBasicHttpException- Parameters:
value- The new value. Can benull to fall back toEnglishReasonPhraseCatalog.INSTANCE.- Returns:
- This object.
-
setStatusCode2
Description copied from class:BasicHttpExceptionSame asBasicHttpException.setStatusCode(int)but returns this object.- Overrides:
setStatusCode2in classBasicHttpException- Parameters:
code- The new status code.- Returns:
- This object.
- Throws:
IllegalStateException- If status code could not be set.
-
setStatusLine
Description copied from class:BasicHttpExceptionSets the protocol version on the status line.If not specified,
"HTTP/1.1" will be used.- Overrides:
setStatusLinein classBasicHttpException- Parameters:
value- The new value. Must not benull .- Returns:
- This object.
-
unmodifiable
Description copied from class:BasicHttpExceptionReturns an unmodifiable snapshot of this bean.The returned instance is a point-in-time copy of the leaf's nested
Unmodifiabletype; any attempt to set a property on it throws anUnsupportedOperationException. This method is idempotent: if this bean is already unmodifiable it returns itself rather than taking another snapshot. The receiver is left unchanged (and still modifiable unless it was already unmodifiable).- Overrides:
unmodifiablein classBasicHttpException- Returns:
- An unmodifiable snapshot of this bean, or this bean if it is already unmodifiable.
-