(err)
| 1 | import ServerlessError from '../../serverless-error.js' |
| 2 | |
| 3 | export const buildV3ProviderError = (err) => { |
| 4 | const statusCode = err?.$metadata?.httpStatusCode |
| 5 | const requestId = err?.$metadata?.requestId |
| 6 | const code = err?.name || err?.code || 'Error' |
| 7 | const retryableNames = new Set([ |
| 8 | 'Throttling', |
| 9 | 'ThrottlingException', |
| 10 | 'TooManyRequestsException', |
| 11 | 'RequestTimeout', |
| 12 | 'NetworkingError', |
| 13 | 'TimeoutError', |
| 14 | 'InternalError', |
| 15 | 'ServiceUnavailable', |
| 16 | ]) |
| 17 | let retryable = |
| 18 | Boolean(err?.$retryable?.throttling) || |
| 19 | retryableNames.has(code) || |
| 20 | (typeof statusCode === 'number' && |
| 21 | (statusCode >= 500 || statusCode === 429)) |
| 22 | return Object.assign({}, err, { |
| 23 | statusCode, |
| 24 | requestId, |
| 25 | code, |
| 26 | retryable, |
| 27 | original: err, |
| 28 | }) |
| 29 | } |
| 30 | |
| 31 | const normalizerPattern = /(?<!^)([A-Z])/g |
| 32 | export const normalizeErrorCodePostfix = (name) => |
no outgoing calls
no test coverage detected
searching dependent graphs…