Skip to content

mapHttpError

mapHttpError(status, body, retryAfterMs?): LoncaError

Defined in: sdks/n11/src/errors.ts:51

Map an n11 HTTP error response to a @lonca/core error.

n11’s three REST path families answer errors differently (observed on prod, 2026-10-10, read-only GETs):

  • /ms/… (products) — a Spring envelope { "@type", name, message, description, urlStack, errors: [{ reason }] }. A wrong appsecret is 401 SellerApiUserUnauthorizedException; a missing auth header and bad parameters (size over 250, an unknown enum value, a negative page) come back as 500 InternalServerException whose message names the Java exception (MissingRequestHeaderException, ConstraintViolationException, IllegalArgumentException, …). Those 500s are client errors, so they map to AuthError / ValidationError instead of a retryable ServerError.
  • /rest/… (orders) — a wrong appsecret is 400 { code, status: "failure", errorCode: "SELLER_API.authenticationFailed", errorMessage, errorCategory }.
  • /cdn/… (categories) — a wrong key is 403 text/plain (“Authentication failed”); an unknown or non-leaf category is 400 { errorCode: "invalidInput", errorMessage }.
  • /ms/product/tasks/… (product writes) — a malformed task (no integrator, empty skus, an unknown enum value, broken JSON) is 500 { errorCode: "TASK_ERR_…", errorMessage } (n11’s test store, 2026-10-13). Also a client error: mapped to ValidationError.

Otherwise the usual status mapping applies:

  • 401 / 403 → AuthError
  • 400 / 422 → ValidationError
  • 404 → NotFoundError
  • 429 → RateLimitError (carries retryAfterMs when the server sent Retry-After). n11 does not send 429 (n11 support, 2026-10-13): bursts get the client IP suspended instead, and what that response looks like is unknown
  • 5xx → ServerError (retryable)
  • other → LoncaError with code UNKNOWN

The raw body stays on error.data.body; user-facing messages are fixed strings so a server message that echoes request context never leaks into logs that print error.message.

number

unknown

number

LoncaError

Unofficial. Lonca is an independent, community-maintained project — not affiliated with, endorsed by, or supported by Trendyol, Hepsiburada, or any other marketplace. All marketplace names and trademarks belong to their respective owners.