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

Method mapByStatusCode

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

* Maps an HTTP status code to the appropriate error class

(status: number, message: string, data: unknown, response?: unknown)

Source from the content-addressed store, hash-verified

159 * Maps an HTTP status code to the appropriate error class
160 */
161 protected mapByStatusCode(status: number, message: string, data: unknown, response?: unknown): BaseError {
162 switch (status) {
163 case 400:
164 return this.mapBadRequestError(message, data);
165 case 401:
166 return new AuthenticationError(message, this.exchangeName);
167 case 403:
168 return new PermissionDenied(message, this.exchangeName);
169 case 404:
170 return this.mapNotFoundError(message, data);
171 case 429:
172 return this.mapRateLimitError(message, response);
173 case 500:
174 case 502:
175 case 503:
176 case 504:
177 return new ExchangeNotAvailable(
178 `Exchange error (${status}): ${message}`,
179 this.exchangeName
180 );
181 default:
182 return new BadRequest(
183 `HTTP ${status}: ${message}`,
184 this.exchangeName
185 );
186 }
187 }
188
189 /**
190 * Maps 400 errors to specific bad request subtypes

Callers 2

mapErrorMethod · 0.95
mapAxiosErrorMethod · 0.95

Calls 3

mapBadRequestErrorMethod · 0.95
mapNotFoundErrorMethod · 0.95
mapRateLimitErrorMethod · 0.95

Tested by

no test coverage detected