MCPcopy
hub / github.com/axios/axios / from

Method from

lib/core/AxiosError.js:76–100  ·  lib/core/AxiosError.js::AxiosError.from
(error, code, config, request, response, customProps)

Source from the content-addressed store, hash-verified

74
75class 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.

Callers 15

index.jsFile · 0.45
transformDataFunction · 0.45
dispatchRequestFunction · 0.45
convertValueFunction · 0.45
resolveConfigFunction · 0.45
fromDataURIFunction · 0.45
formDataToStreamFunction · 0.45
factoryFunction · 0.45
xhr.jsFile · 0.45
onloadendFunction · 0.45
setProxyFunction · 0.45
http.jsFile · 0.45

Calls

no outgoing calls

Tested by 10

collectFunction · 0.36
endMethod · 0.36
writeFunction · 0.36
writeFunction · 0.36
requestFunction · 0.36
writeFunction · 0.36
writeFunction · 0.36
requestFunction · 0.36
writeFunction · 0.36
requestFunction · 0.36