Class RateLimitedException

  • All Implemented Interfaces:
    Serializable

    public class RateLimitedException
    extends RuntimeException
    Indicates that the Wrapper got rate limited by the BotBlock API.
    Use getDelay() to find out how long you have to wait until you can perform another request towards the 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 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) then null 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) then null 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) then null 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.
        Overrides:
        toString in class Throwable
        Returns:
        RatelimitedException{delay=<delay>, botId=<botId>, ip=<ip>, route=<route>}
      • getMessage

        public String getMessage()
        Returns a message informing us about where we got rate limited, for how long and on what bot id and ip.
        Overrides:
        getMessage in class Throwable
        Returns:
        String containing a message with route, delay, bot id and IP.