Skip to content

Commit 2f763ef

Browse files
committed
move SuspendExecutionException to under Error
1 parent e0e9818 commit 2f763ef

4 files changed

Lines changed: 21 additions & 11 deletions

File tree

sdk-integration-tests/src/test/java/software/amazon/lambda/durable/CallbackIntegrationTest.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,9 @@ void waitForCallbackCallbackFailed() {
271271
ctx.waitForCallback("approval", String.class, (callbackId, stepCtx) -> {});
272272
fail();
273273
return "should not reach here";
274+
} catch (SuspendExecutionException e) {
275+
throw e;
274276
} catch (Exception e) {
275-
if (e instanceof SuspendExecutionException) {
276-
throw e;
277-
}
278277
assertInstanceOf(CallbackFailedException.class, e);
279278
throw e;
280279
}
@@ -309,10 +308,9 @@ void waitForCallbackCallbackTimeout() {
309308
ctx.waitForCallback("approval", String.class, (callbackId, stepCtx) -> {});
310309
fail();
311310
return "should not reach here";
311+
} catch (SuspendExecutionException e) {
312+
throw e;
312313
} catch (Exception e) {
313-
if (e instanceof SuspendExecutionException) {
314-
throw e;
315-
}
316314
assertInstanceOf(CallbackTimeoutException.class, e);
317315
throw e;
318316
}
@@ -339,10 +337,9 @@ void waitForCallbackCallbackFailedWithUserException() {
339337
// original exception
340338
throw new IllegalArgumentException(errorMessage);
341339
});
340+
} catch (SuspendExecutionException e) {
341+
throw e;
342342
} catch (Exception e) {
343-
if (e instanceof SuspendExecutionException) {
344-
throw e;
345-
}
346343
assertInstanceOf(IllegalArgumentException.class, e);
347344
assertEquals(errorMessage, e.getMessage());
348345
throw e;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
package software.amazon.lambda.durable.execution;
4+
5+
/**
6+
* A throwable error that can be used internally by Durable Execution SDK. Users of the SDK should not throw this error
7+
* directly or catch this error in their code.
8+
*/
9+
public class DurableExecutionError extends Error {
10+
public DurableExecutionError(String message) {
11+
super(message);
12+
}
13+
}

sdk/src/main/java/software/amazon/lambda/durable/execution/ExecutionManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ public boolean isExecutionCompletedExceptionally() {
351351
return executionExceptionFuture.isCompletedExceptionally();
352352
}
353353

354-
private void stopAllOperations(Exception cause) {
354+
private void stopAllOperations(Throwable cause) {
355355
registeredOperations.values().forEach(op -> op.getCompletionFuture().completeExceptionally(cause));
356356
}
357357

sdk/src/main/java/software/amazon/lambda/durable/execution/SuspendExecutionException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
package software.amazon.lambda.durable.execution;
44

55
/** Exception thrown to suspend execution during wait operations. This is an internal control flow mechanism. */
6-
public class SuspendExecutionException extends RuntimeException {
6+
public class SuspendExecutionException extends DurableExecutionError {
77
public SuspendExecutionException() {
88
super("Execution suspended for wait operation");
99
}

0 commit comments

Comments
 (0)