Skip to content

Errors & validation helpers

Nene2ClientError

PropertyDescription
statusHTTP status (0 = network/abort/timeout)
urlRequest URL
problemParsed Problem Details, if body matched
rateLimitRetry-After / X-RateLimit-* when present

isNene2ClientError(error) type guard — use for all client failures including DNS and connection errors.

Rate limit backoff (429)

When the server sends rate-limit headers, they appear on error.rateLimit:

ts
catch (error) {
  if (isNene2ClientError(error) && error.status === 429 && error.rateLimit?.retryAfterSeconds) {
    await sleep(error.rateLimit.retryAfterSeconds * 1000);
  }
}

parseRateLimitHeaders(headers) is exported for custom fetch wrappers.

Validation helpers

ExportUse
validationErrorsFromClientErrorerrors[] from a client error
validationErrorsByFieldMap field → messages
isNene2ValidationFailedProblemNarrow Problem document
NENE2_PROBLEM_TYPE_VALIDATION_FAILEDConstant type URI

Standalone Problem Details

Exported without the client: parseProblemDetails, isProblemDetails, isValidationProblemDetails, problemDetailsExtensions, etc.

Useful for middleware or custom fetch wrappers in consumer apps.

Released under the MIT License.