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

Method mapBadRequestError

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

* Maps 400 errors to specific bad request subtypes

(message: string, data: unknown)

Source from the content-addressed store, hash-verified

190 * Maps 400 errors to specific bad request subtypes
191 */
192 protected mapBadRequestError(message: string, data: unknown): BadRequest {
193 const lowerMessage = message.toLowerCase();
194
195 // Detect insufficient funds
196 if (
197 lowerMessage.includes('insufficient') ||
198 lowerMessage.includes('balance') ||
199 lowerMessage.includes('not enough')
200 ) {
201 return new InsufficientFunds(message, this.exchangeName);
202 }
203
204 // Detect invalid order
205 if (
206 lowerMessage.includes('invalid order') ||
207 lowerMessage.includes('invalid orderid') ||
208 lowerMessage.includes('invalid order id') ||
209 lowerMessage.includes('tick size') ||
210 lowerMessage.includes('price must be') ||
211 lowerMessage.includes('size must be') ||
212 lowerMessage.includes('amount must be')
213 ) {
214 return new InvalidOrder(message, this.exchangeName);
215 }
216
217 // Detect validation errors
218 if (lowerMessage.includes('validation') || lowerMessage.includes('invalid parameter')) {
219 return new ValidationError(message, undefined, this.exchangeName);
220 }
221
222 return new BadRequest(message, this.exchangeName);
223 }
224
225 /**
226 * Maps 404 errors to specific not found subtypes

Callers 1

mapByStatusCodeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected