Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Feature]: Use specific exception types in step error handling #14

@phipag

Description

@phipag

What would you like?

Currently, we are always throwing a StepFailedException when a step fails terminally.

} 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:

Is this a breaking change?

No

Does this require an RFC?

No

Additional Context

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions