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

Method mapNotFoundError

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

* Maps 404 errors to specific not found subtypes

(message: string, data: unknown)

Source from the content-addressed store, hash-verified

226 * Maps 404 errors to specific not found subtypes
227 */
228 protected mapNotFoundError(message: string, data: unknown): NotFound {
229 const lowerMessage = message.toLowerCase();
230
231 // Detect order not found (but not "order book" — that's a different resource)
232 if (lowerMessage.includes('order') && !lowerMessage.includes('order book')) {
233 // Try to extract order ID from message
234 const orderIdMatch = message.match(/order[:\s]+([a-zA-Z0-9-]+)/i);
235 const orderId = orderIdMatch ? orderIdMatch[1] : 'unknown';
236 return new OrderNotFound(orderId, this.exchangeName);
237 }
238
239 // Detect market not found
240 if (lowerMessage.includes('market')) {
241 // Try to extract market ID from message
242 const marketIdMatch = message.match(/market[:\s]+([a-zA-Z0-9-]+)/i);
243 const marketId = marketIdMatch ? marketIdMatch[1] : 'unknown';
244 return new MarketNotFound(marketId, this.exchangeName);
245 }
246
247 // Generic "not found" - could be order or market depending on context
248 // Since we can't determine context here, return generic NotFound
249 // The calling code (exchange implementations) should handle this appropriately
250 return new NotFound(message, this.exchangeName);
251 }
252
253 /**
254 * Maps rate limit errors

Callers 1

mapByStatusCodeMethod · 0.95

Calls 1

matchMethod · 0.45

Tested by

no test coverage detected