How can I extract the type of an activity failure? So I have a workflow that does this:
export const workflow = async params => {
try {
const result = await activityA(params);
return await activityB(result);
} catch (err) {
if (err) {
await handleActivityFailure(err as Error);
}
throw err;
}
};
with my activities throwing errors via:
throw ApplicationFailure.nonRetryable('Error found', 'errorA' );
In that line where I have if (err)
, I’d actually like to retrieve and check the type of error being thrown (I’d like to only call handleActivityFailure
if the activity type is of type errorA).
What’s the best way to do so? When I print out what the value of err
is, I get, which seems like a really weird object being returned?
[activityA(aec6094f-c8cb-4bda-9bc5-2d79633272dc)] [ActivityFailure: Activity execution failed] {
cause: ApplicationFailure: Error found
at Function.nonRetryable
at activityA[as fn] {
cause: undefined,
type: 'THING_I_WANT_TO_GET',
nonRetryable: true,
details: [],
failure: Failure {
message: 'Error found ',
source: 'TypeScriptSDK',
stackTrace: 'ApplicationFailure: Error found \n' +
}
},
activityType: 'activityA',
activityId: '3',
retryState: 2,
identity: '55703@ip-192-168-1-162.us-west-2.compute.internal',
failure: Failure {
message: 'Activity task failed',
cause: Failure {
message: 'Error found',
source: 'TypeScriptSDK',
stackTrace: '',
applicationFailureInfo: [ApplicationFailureInfo]
},
activityFailureInfo: ActivityFailureInfo {
scheduledEventId: [Long],
startedEventId: [Long],
identity: '55703@ip-192-168-1-162.us-west-2.compute.internal',
activityType: [ActivityType],
activityId: '3',
retryState: 2
}
}
}