-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
enhancementNew feature or requestNew feature or request
Description
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:
one-sdk-js/src/core/events/failure/policy.ts
Lines 119 to 148 in fbf5e4c
| 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
Labels
enhancementNew feature or requestNew feature or request