Skip to content

Commit ee5e4cb

Browse files
committed
PR aws-powertools#717: document exceptions
1 parent 03b7b6c commit ee5e4cb

8 files changed

+37
-2
lines changed

powertools-idempotency/src/main/java/software/amazon/lambda/powertools/idempotency/exceptions/IdempotencyAlreadyInProgressException.java

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
*/
1414
package software.amazon.lambda.powertools.idempotency.exceptions;
1515

16+
/**
17+
* This exception is thrown when the same payload is sent
18+
* while the previous one was not yet fully stored in the persistence layer (marked as COMPLETED).
19+
*/
1620
public class IdempotencyAlreadyInProgressException extends RuntimeException {
1721
private static final long serialVersionUID = 7229475093418832265L;
1822

powertools-idempotency/src/main/java/software/amazon/lambda/powertools/idempotency/exceptions/IdempotencyConfigurationException.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@
1313
*/
1414
package software.amazon.lambda.powertools.idempotency.exceptions;
1515

16-
public class IdempotencyConfigurationException extends RuntimeException{
16+
/**
17+
* Exception thrown when Idempotency is not well configured:
18+
* <ul>
19+
* <li>An annotated method does not return anything</li>
20+
* <li>An annotated method does not have parameters or more than one without
21+
* the {@link software.amazon.lambda.powertools.idempotency.IdempotencyKey} annotation</li>
22+
* </ul>
23+
*/
24+
public class IdempotencyConfigurationException extends RuntimeException {
1725
private static final long serialVersionUID = 560587720373305487L;
1826

1927
public IdempotencyConfigurationException(String message) {

powertools-idempotency/src/main/java/software/amazon/lambda/powertools/idempotency/exceptions/IdempotencyInconsistentStateException.java

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
*/
1414
package software.amazon.lambda.powertools.idempotency.exceptions;
1515

16+
/**
17+
* IdempotencyInconsistentStateException can happen under rare but expected cases
18+
* when persistent state changes in the small-time between put & get requests.
19+
*/
1620
public class IdempotencyInconsistentStateException extends RuntimeException {
1721
private static final long serialVersionUID = -4293951999802300672L;
1822

powertools-idempotency/src/main/java/software/amazon/lambda/powertools/idempotency/exceptions/IdempotencyItemAlreadyExistsException.java

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
*/
1414
package software.amazon.lambda.powertools.idempotency.exceptions;
1515

16+
/**
17+
* Exception thrown when trying to store an item which already exists.
18+
*/
1619
public class IdempotencyItemAlreadyExistsException extends RuntimeException {
1720
private static final long serialVersionUID = 9027152772149436500L;
1821

powertools-idempotency/src/main/java/software/amazon/lambda/powertools/idempotency/exceptions/IdempotencyItemNotFoundException.java

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
*/
1414
package software.amazon.lambda.powertools.idempotency.exceptions;
1515

16+
/**
17+
* Exception thrown when the item was not found in the persistence store.
18+
*/
1619
public class IdempotencyItemNotFoundException extends RuntimeException{
1720
private static final long serialVersionUID = 4818288566747993032L;
1821

powertools-idempotency/src/main/java/software/amazon/lambda/powertools/idempotency/exceptions/IdempotencyKeyException.java

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
*/
1414
package software.amazon.lambda.powertools.idempotency.exceptions;
1515

16+
/**
17+
* Exception thrown only when using {@link software.amazon.lambda.powertools.idempotency.IdempotencyConfig#throwOnNoIdempotencyKey()},
18+
* and if a key could not be found in the event (for example when having a bad JMESPath configured)
19+
*/
1620
public class IdempotencyKeyException extends RuntimeException {
1721
private static final long serialVersionUID = -8514965705001281773L;
1822

powertools-idempotency/src/main/java/software/amazon/lambda/powertools/idempotency/exceptions/IdempotencyPersistenceLayerException.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
*/
1414
package software.amazon.lambda.powertools.idempotency.exceptions;
1515

16-
public class IdempotencyPersistenceLayerException extends RuntimeException{
16+
/**
17+
* Exception thrown when a technical error occurred with the persistence layer (eg. insertion, deletion, ... in database)
18+
*/
19+
public class IdempotencyPersistenceLayerException extends RuntimeException {
1720
private static final long serialVersionUID = 6781832947434168547L;
1821

1922
public IdempotencyPersistenceLayerException(String msg, Exception e) {

powertools-idempotency/src/main/java/software/amazon/lambda/powertools/idempotency/exceptions/IdempotencyValidationException.java

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
*/
1414
package software.amazon.lambda.powertools.idempotency.exceptions;
1515

16+
import software.amazon.lambda.powertools.idempotency.IdempotencyConfig;
17+
18+
/**
19+
* Exception thrown only when using {@link IdempotencyConfig#getPayloadValidationJMESPath()} is configured
20+
* and the payload changed between two calls (but with the same idempotency key).
21+
*/
1622
public class IdempotencyValidationException extends RuntimeException {
1723
private static final long serialVersionUID = -4218652810664634761L;
1824

0 commit comments

Comments
 (0)