generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 1
Closed
Labels
Description
What would you like?
Currently, we are always throwing a StepFailedException when a step fails terminally.
Lines 346 to 376 in fe12ac7
| } else { | |
| // It failed so there's some kind of throwable. If we're using a serDes with | |
| // type info, deserialize and rethrow the original | |
| // throwable. Otherwise, throw a new StepFailedException that includes info | |
| // about the original throwable. | |
| // TODO: Enable this feature after introducing polymorphic object mapper | |
| // support. | |
| // String errorData = op.stepDetails().error().errorData(); | |
| // if (errorData != null && serDes.supportsIncludingTypeInfo()) { | |
| // SneakyThrow.sneakyThrow((Throwable) | |
| // serDes.deserializeWithTypeInfo(errorData)); | |
| // } | |
| var errorType = op.stepDetails().error().errorType(); | |
| // Throw StepInterruptedException directly for AT_MOST_ONCE interrupted steps | |
| // Todo: Change once errorData object is implemented | |
| if ("StepInterruptedException".equals(errorType)) { | |
| throw new StepInterruptedException(operationId, name); | |
| } | |
| throw new StepFailedException( | |
| String.format( | |
| "Step failed with error of type %s. Message: %s", | |
| errorType, op.stepDetails().error().errorMessage()), | |
| null, | |
| // Preserve original stack trace | |
| StepFailedException.deserializeStackTrace( | |
| op.stepDetails().error().stackTrace())); | |
| } |
This behavior is not ideal because users expect (and this aligns with the other SDK implementations) to be able to catch the original exception that might be thrown from a step. The complexity of this feature is to restore the specific Exception type from the checkpointed ErrorObject data.
Possible Implementation
The ErrorObject (https://docs.aws.amazon.com/lambda/latest/api/API_ErrorObject.html) contains the following fields which are necessary to restore. This is possible by leveraging these fields:
- ErrorData (serialized Exception using SerDes when checkpointing error)
- ErrorType (fully qualified class name of original exception type)
A possible implementation can attempt to:
- Load original
ErrorTypeusing Java reflection- If class not found, fall back to
StepFailedException
- If class not found, fall back to
- Check if
ErrorTypeis assignable fromThrowable - Deserialize
ErrorDatainto dynamically loadedErrorType - Sneaky throw original exception. Needed because Throwable is a checked exception ...
Is this a breaking change?
No
Does this require an RFC?
No
Additional Context
No response
Reactions are currently unavailable