Class RateLimitedException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- org.botblock.javabotblockapi.core.exceptions.RateLimitedException
-
- All Implemented Interfaces:
Serializable
public class RateLimitedException extends RuntimeException
Indicates that the Wrapper got rate limited by the BotBlock API.
UsegetDelay()
to find out how long you have to wait until you can perform another request towardsthe targeted route
.Note that this Wrapper will do no attempt at delaying any further requests! It is your own responsibility to handle rate limits properly in those cases and delay any future requests accordingly.
Any automated POSTing method of this Wrapper should not get rate limited due to keeping a minimal delay between each request that is more than enough.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description RateLimitedException(JSONObject json)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getBotId()
Returns the bot id that was rate limited.int
getDelay()
Returns the delay - in milliseconds - you have to wait to perform a request again.String
getIp()
Returns the ip that was rate limited.String
getMessage()
Returns a message informing us aboutwhere
we got rate limited,for how long
and on whatbot id
andip
.String
getRoute()
Returns the route on which the bot was rate limited.String
toString()
Returns this class formatted to a String.-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
-
-
-
Constructor Detail
-
RateLimitedException
public RateLimitedException(JSONObject json)
-
-
Method Detail
-
getDelay
public int getDelay()
Returns the delay - in milliseconds - you have to wait to perform a request again.
When no delay could be extracted from the received JSON (The JSON was malformed) then-1
will be returned.- Returns:
- The delay you have to wait in milliseconds or
-1
.
-
getBotId
@Nullable public String getBotId()
Returns the bot id that was rate limited.
When no botId could be extracted from the received JSON (The JSON was malformed) thennull
will be returned.- Returns:
- Possibly-null String representing the id of the rate limited bot.
-
getIp
public String getIp()
Returns the ip that was rate limited.
When no ip could be extracted from the received JSON (The JSON was malformed) thennull
will be returned.- Returns:
- Possibly-null String representing the ip of the rate limited bot.
-
getRoute
public String getRoute()
Returns the route on which the bot was rate limited.
When no route could be extracted from the received JSON (The JSON was malformed) thennull
will be returned.- Returns:
- Possibly-null String representing the route on which the bot got rate limited.
-
toString
public String toString()
Returns this class formatted to a String.
-
getMessage
public String getMessage()
Returns a message informing us aboutwhere
we got rate limited,for how long
and on whatbot id
andip
.- Overrides:
getMessage
in classThrowable
- Returns:
- String containing a message with route, delay, bot id and IP.
-
-