Skip to content

[Enhancement] Cannot identify the root cause of SdkExecutionError #286

Open
@jnv

Description

@jnv

When the request ends with timeout or network error, I get just a generic SdkExecutionError with the root cause buried in the message, for example: Request ended with network error: timeout.

This makes representing the error to the end user harder, for example in OneService we want to format the error into a GraphQL-compliant structure and expose the root cause to the client, so they can react accordingly.

I think what would help here is to either keep the original failure packed in the returned error, or at least pass its kind.

Relevant code:

public toError(): Error {
switch (this.data.kind) {
case 'failure':
return new SDKExecutionError(
FailurePolicyReason.failureToString(this.data.failure),
[
`At ${new Date(this.data.failure.time).toISOString()}`,
this.prefixMessages.join(': '),
],
[]
);
case 'policy':
return new SDKExecutionError(
`Failure policy aborted with reason:' ${this.data.reason}`,
[this.prefixMessages.join(': ')],
['Check that the failure policy is correctly configured']
);
}
}
private static failureToString(failure: ExecutionFailure): string {
if (failure.kind === 'http') {
return `Request ended with ${failure.kind} error, status code: ${failure.response.statusCode}`;
} else if (failure.kind === 'request' || failure.kind === 'network') {
return `Request ended with ${failure.kind} error: ${failure.issue}`;
} else {
return `Request ended with error: ${failure.originalError.toString()}`;
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions