MCPcopy Index your code
hub / github.com/pmxt-dev/pmxt / mapAxiosError

Method mapAxiosError

core/src/utils/error-mapper.ts:136–156  ·  view source on GitHub ↗

* Maps axios HTTP errors to appropriate error classes

(error: AxiosError)

Source from the content-addressed store, hash-verified

134 * Maps axios HTTP errors to appropriate error classes
135 */
136 protected mapAxiosError(error: AxiosError): BaseError {
137 const status = error.response?.status;
138 const message = this.extractErrorMessage(error);
139 const data = error.response?.data;
140
141 // Network/connection errors
142 if (!status) {
143 if (error.code === 'ECONNABORTED' || error.code === 'ETIMEDOUT') {
144 return new NetworkError(
145 `Request timeout: ${message}`,
146 this.exchangeName
147 );
148 }
149 return new ExchangeNotAvailable(
150 `Exchange unreachable: ${message}`,
151 this.exchangeName
152 );
153 }
154
155 return this.mapByStatusCode(status, message, data, error.response);
156 }
157
158 /**
159 * Maps an HTTP status code to the appropriate error class

Callers 1

mapErrorMethod · 0.95

Calls 2

extractErrorMessageMethod · 0.95
mapByStatusCodeMethod · 0.95

Tested by

no test coverage detected