( data: TrpcErrorData, message: string, cause?: unknown )
| 70 | |
| 71 | export function createClientError(code: string, message: string, retryable?: boolean): ClientError { |
| 72 | return { |
| 73 | code, |
| 74 | message, |
| 75 | retryable: NON_RETRYABLE_CODES.has(code) ? false : (retryable ?? true), |
| 76 | }; |
| 77 | } |
| 78 | |
| 79 | export function projectTrpcErrorData( |
| 80 | data: TrpcErrorData, |
| 81 | message: string, |
| 82 | cause?: unknown |
| 83 | ): TrpcErrorData & { clientError: ClientError } { |
| 84 | const explicitCause = parseExplicitLegacyCause(cause); |
| 85 | const billingFailure = parseBillingFailure(cause); |
| 86 | if (explicitCause) { |
| 87 | const clientError = createClientError(explicitCause.error, message, explicitCause.retryable); |
| 88 | return { |
| 89 | ...data, |
| 90 | error: explicitCause.error, |
| 91 | retryable: clientError.retryable, |
| 92 | clientError, |
| 93 | ...(billingFailure ? { billingFailure } : {}), |
| 94 | }; |
no test coverage detected