(error, code, config, request, response, customProps)
| 74 | |
| 75 | class AxiosError extends Error { |
| 76 | static from(error, code, config, request, response, customProps) { |
| 77 | const axiosError = new AxiosError(error.message, code || error.code, config, request, response); |
| 78 | class="cm">// Match native `Error` `cause` semantics: non-enumerable. The wrapped |
| 79 | class="cm">// error often carries circular internals (sockets, requests, agents), so |
| 80 | class="cm">// an enumerable `cause` makes structured loggers (pino/winston) and any |
| 81 | class="cm">// own-property walk throw class="st">"Converting circular structure to JSON". |
| 82 | class="cm">// Regression from #6982; see #7205. `__proto__: null` mirrors the |
| 83 | class="cm">// `message` descriptor below (prototype-pollution-safe descriptor). |
| 84 | Object.defineProperty(axiosError, class="st">'cause', { |
| 85 | __proto__: null, |
| 86 | value: error, |
| 87 | writable: true, |
| 88 | enumerable: false, |
| 89 | configurable: true, |
| 90 | }); |
| 91 | axiosError.name = error.name; |
| 92 | |
| 93 | class="cm">// Preserve status from the original error if not already set from response |
| 94 | if (error.status != null && axiosError.status == null) { |
| 95 | axiosError.status = error.status; |
| 96 | } |
| 97 | |
| 98 | customProps && Object.assign(axiosError, customProps); |
| 99 | return axiosError; |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Create an Error with the specified message, config, error code, request and response. |
no outgoing calls