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 wrongappsecretis401 SellerApiUserUnauthorizedException; a missing auth header and bad parameters (sizeover 250, an unknown enum value, a negative page) come back as500 InternalServerExceptionwhosemessagenames the Java exception (MissingRequestHeaderException,ConstraintViolationException,IllegalArgumentException, …). Those 500s are client errors, so they map toAuthError/ValidationErrorinstead of a retryableServerError./rest/…(orders) — a wrongappsecretis400 { code, status: "failure", errorCode: "SELLER_API.authenticationFailed", errorMessage, errorCategory }./cdn/…(categories) — a wrong key is403 text/plain(“Authentication failed”); an unknown or non-leaf category is400 { errorCode: "invalidInput", errorMessage }./ms/product/tasks/…(product writes) — a malformed task (nointegrator, emptyskus, an unknown enum value, broken JSON) is500 { errorCode: "TASK_ERR_…", errorMessage }(n11’s test store, 2026-10-13). Also a client error: mapped toValidationError.
Otherwise the usual status mapping applies:
401/403→AuthError400/422→ValidationError404→NotFoundError429→RateLimitError(carriesretryAfterMswhen the server sentRetry-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 unknown5xx→ServerError(retryable)- other →
LoncaErrorwith codeUNKNOWN
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.
Parameters
Section titled “Parameters”status
Section titled “status”number
unknown
retryAfterMs?
Section titled “retryAfterMs?”number
Returns
Section titled “Returns”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.