Package org.javacord.core.util.rest
Enum RestRequestHttpResponseCode
- java.lang.Object
-
- java.lang.Enum<RestRequestHttpResponseCode>
-
- org.javacord.core.util.rest.RestRequestHttpResponseCode
-
- All Implemented Interfaces:
Serializable
,Comparable<RestRequestHttpResponseCode>
public enum RestRequestHttpResponseCode extends Enum<RestRequestHttpResponseCode>
An enum with all rest request result codes as defined by Discord.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description BAD_REQUEST
The request was improperly formatted, or the server couldn't understand it.CREATED
The entity was created successfully.FORBIDDEN
The Authorization token you passed did not have permission to the resource.GATEWAY_UNAVAILABLE
There was not a gateway available to process your request.METHOD_NOT_ALLOWED
The HTTP method used is not valid for the location specified.NO_CONTENT
The request completed successfully but returned no content.NOT_FOUND
The resource at the location specified doesn't exist.NOT_MODIFIED
The entity was not modified (no action was taken).OK
The request completed successfully.TOO_MANY_REQUESTS
You've made too many requests.UNAUTHORIZED
The Authorization header was missing or invalid.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Optional<RestRequestHttpResponseCode>
fromCode(int code)
Gets the rest request http response code by actual numeric response code.static Optional<RestRequestHttpResponseCode>
fromDiscordExceptionClass(Class<? extends DiscordException> discordExceptionClass)
Gets the rest request http response code by discord exception class.int
getCode()
Gets the actual numeric response code.Optional<? extends DiscordException>
getDiscordException(Exception origin, String message, RestRequestInformation request, RestRequestResponseInformation response)
Gets the discord exception to throw for this kind of result code.Optional<? extends Class<? extends DiscordException>>
getDiscordExceptionClass()
Gets the discord exception class to throw for this kind of result code.String
getMeaning()
Gets the textual meaning.static RestRequestHttpResponseCode
valueOf(String name)
Returns the enum constant of this type with the specified name.static RestRequestHttpResponseCode[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
OK
public static final RestRequestHttpResponseCode OK
The request completed successfully.
-
CREATED
public static final RestRequestHttpResponseCode CREATED
The entity was created successfully.
-
NO_CONTENT
public static final RestRequestHttpResponseCode NO_CONTENT
The request completed successfully but returned no content.
-
NOT_MODIFIED
public static final RestRequestHttpResponseCode NOT_MODIFIED
The entity was not modified (no action was taken).
-
BAD_REQUEST
public static final RestRequestHttpResponseCode BAD_REQUEST
The request was improperly formatted, or the server couldn't understand it.
-
UNAUTHORIZED
public static final RestRequestHttpResponseCode UNAUTHORIZED
The Authorization header was missing or invalid.
-
FORBIDDEN
public static final RestRequestHttpResponseCode FORBIDDEN
The Authorization token you passed did not have permission to the resource.
-
NOT_FOUND
public static final RestRequestHttpResponseCode NOT_FOUND
The resource at the location specified doesn't exist.
-
METHOD_NOT_ALLOWED
public static final RestRequestHttpResponseCode METHOD_NOT_ALLOWED
The HTTP method used is not valid for the location specified.
-
TOO_MANY_REQUESTS
public static final RestRequestHttpResponseCode TOO_MANY_REQUESTS
You've made too many requests.- See Also:
- Rate Limits
-
GATEWAY_UNAVAILABLE
public static final RestRequestHttpResponseCode GATEWAY_UNAVAILABLE
There was not a gateway available to process your request. Wait a bit and retry.
-
-
Method Detail
-
values
public static RestRequestHttpResponseCode[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (RestRequestHttpResponseCode c : RestRequestHttpResponseCode.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static RestRequestHttpResponseCode valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
fromCode
public static Optional<RestRequestHttpResponseCode> fromCode(int code)
Gets the rest request http response code by actual numeric response code.- Parameters:
code
- The actual numeric response code.- Returns:
- The rest request http response code with the actual numeric response code.
-
fromDiscordExceptionClass
public static Optional<RestRequestHttpResponseCode> fromDiscordExceptionClass(Class<? extends DiscordException> discordExceptionClass)
Gets the rest request http response code by discord exception class. If no entry for the given class is found, the parents are checked until match is found orDiscordException
is reached.- Parameters:
discordExceptionClass
- The discord exception class.- Returns:
- The rest request http response code with the discord exception class.
-
getCode
public int getCode()
Gets the actual numeric response code.- Returns:
- The actual numeric response code.
-
getMeaning
public String getMeaning()
Gets the textual meaning.- Returns:
- The textual meaning.
-
getDiscordException
public Optional<? extends DiscordException> getDiscordException(Exception origin, String message, RestRequestInformation request, RestRequestResponseInformation response)
Gets the discord exception to throw for this kind of result code.- Parameters:
origin
- The origin of the exception.message
- The message of the exception.request
- The information about the request.response
- The information about the response.- Returns:
- The discord exception to throw for this kind of result code.
-
getDiscordExceptionClass
public Optional<? extends Class<? extends DiscordException>> getDiscordExceptionClass()
Gets the discord exception class to throw for this kind of result code.- Returns:
- The discord exception class to throw for this kind of result code.
-
-