mattrguerra/meridian-orders-mcpmainPrivate on GitHub, published here in full

errors.ts

Language TypeScript913 B30 lines

mcp-server/src/lib/errors.ts

  1. /** Raised when the environment is not configured for live requests. */
  2. export class ConfigError extends Error {
  3. constructor(message: string) {
  4. super(message);
  5. this.name = "ConfigError";
  6. }
  7. }
  8. /**
  9. * Wraps one of the API's several documented error shapes:
  10. * {"error": "Invalid request"} | {"notice": "No match"} | ...
  11. * `raw` preserves the body so callers can disambiguate (e.g. treat
  12. * orders.splitShipments "No match" as "not multi-address").
  13. */
  14. export class PlinthApiError extends Error {
  15. readonly raw: unknown;
  16. constructor(message: string, raw: unknown) {
  17. super(message);
  18. this.name = "PlinthApiError";
  19. this.raw = raw;
  20. }
  21. }
  22. /** The API's fixed rate limit was hit: 10 requests / 10 seconds. */
  23. export class RateLimitError extends PlinthApiError {
  24. constructor(raw: unknown) {
  25. super("Too many requests. Slow down and retry.", raw);
  26. this.name = "RateLimitError";
  27. }
  28. }