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

Method from

lib/core/AxiosError.js:76–100  ·  view source on GitHub ↗
(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 // Match native `Error` `cause` semantics: non-enumerable. The wrapped
79 // error often carries circular internals (sockets, requests, agents), so
80 // an enumerable `cause` makes structured loggers (pino/winston) and any
81 // own-property walk throw "Converting circular structure to JSON".
82 // Regression from #6982; see #7205. `__proto__: null` mirrors the
83 // `message` descriptor below (prototype-pollution-safe descriptor).
84 Object.defineProperty(axiosError, 'cause', {
85 __proto__: null,
86 value: error,
87 writable: true,
88 enumerable: false,
89 configurable: true,
90 });
91 axiosError.name = error.name;
92
93 // 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