summaryrefslogtreecommitdiff
path: root/src/io/RateLimitException.java
blob: e196702f5a187a9d710cc6af49c1ea078ea72387 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package io;

/**
 * The exception that will be thrown when a ratelimit has been hit.
 *
 * @author Maurice Laveaux
 */
public class RateLimitException extends Exception {

    private final long rateLimitReset;

    public RateLimitException(long resetTime) {
        rateLimitReset = resetTime;
    }

    public long getResetTime() {
        return rateLimitReset;
    }

    /**
     * @return Time in milliseconds that should be waited for before a new
     * similar request can be executed.
     */
    public long getRateLimitRemainingTime() {
        return rateLimitReset * 1000 - System.currentTimeMillis();
    }
}