mirror of https://github.com/shred/acme4j
Add a rate limit exception
parent
fa31a1cf94
commit
06ccd6f2e1
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* acme4j - Java ACME client
|
||||||
|
*
|
||||||
|
* Copyright (C) 2015 Richard "Shred" Körber
|
||||||
|
* http://acme4j.shredzone.org
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*/
|
||||||
|
package org.shredzone.acme4j.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An exception that is thrown when a rate limit was exceeded.
|
||||||
|
*
|
||||||
|
* @author Richard "Shred" Körber
|
||||||
|
*/
|
||||||
|
public class AcmeRateLimitExceededException extends AcmeServerException {
|
||||||
|
private static final long serialVersionUID = 4150484059796413069L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link AcmeRateLimitExceededException}.
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* System readable error type (here {@code "urn:acme:error:rateLimited"})
|
||||||
|
* @param detail
|
||||||
|
* Human readable error message
|
||||||
|
*/
|
||||||
|
public AcmeRateLimitExceededException(String type, String detail) {
|
||||||
|
super(type, detail);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -43,6 +43,7 @@ import org.shredzone.acme4j.connector.HttpConnector;
|
||||||
import org.shredzone.acme4j.connector.Resource;
|
import org.shredzone.acme4j.connector.Resource;
|
||||||
import org.shredzone.acme4j.connector.Session;
|
import org.shredzone.acme4j.connector.Session;
|
||||||
import org.shredzone.acme4j.exception.AcmeException;
|
import org.shredzone.acme4j.exception.AcmeException;
|
||||||
|
import org.shredzone.acme4j.exception.AcmeRateLimitExceededException;
|
||||||
import org.shredzone.acme4j.exception.AcmeServerException;
|
import org.shredzone.acme4j.exception.AcmeServerException;
|
||||||
import org.shredzone.acme4j.exception.AcmeUnauthorizedException;
|
import org.shredzone.acme4j.exception.AcmeUnauthorizedException;
|
||||||
import org.shredzone.acme4j.util.ClaimBuilder;
|
import org.shredzone.acme4j.util.ClaimBuilder;
|
||||||
|
@ -334,6 +335,9 @@ public class DefaultConnection implements Connection {
|
||||||
case "urn:acme:error:unauthorized":
|
case "urn:acme:error:unauthorized":
|
||||||
throw new AcmeUnauthorizedException(type, detail);
|
throw new AcmeUnauthorizedException(type, detail);
|
||||||
|
|
||||||
|
case "urn:acme:error:rateLimited":
|
||||||
|
throw new AcmeRateLimitExceededException(type, detail);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new AcmeServerException(type, detail);
|
throw new AcmeServerException(type, detail);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue