NexoFlow
Docs · nexoflow-sdk Errors

Technical SEOnexoflow-sdk

Error handling

Every failed call throws a NexoFlowError, so you can branch on the HTTP status, a structured code or a few convenience flags.

Example

errors.ts
import { NexoFlow, NexoFlowError } from "nexoflow-sdk"

try {
  const { data } = await nf.posts.get("nonexistent")
} catch (err) {
  if (err instanceof NexoFlowError) {
    console.log(err.status)          // 404
    console.log(err.code)            // "HTTP_404"
    console.log(err.message)         // "Post not found."
    console.log(err.traceId)         // "nf_…", also sent as X-Request-Id
    console.log(err.attempts)        // 1 (404s aren't retried)
    console.log(err.isNotFound)      // true
    console.log(err.isUnauthorized)  // false
    console.log(err.isRateLimited)   // false
  }
}

Properties

PropertyWhat it tells you
statusHTTP status (404, 401, 500…), or 0 when there was no answer (a network error or timeout)
codeHTTP_ plus the status (the Content API sends no code of its own), or TIMEOUT / NETWORK_ERROR when the status is 0
messageThe API's message, written to be read
traceIdThe SDK's id for the call, also sent as X-Request-Id, to match it in your own logs
requestId, detailsFilled only when an error body carries them; the Content API's errors don't
attempts, elapsedMsHow many tries were made, and how long they took in all
isNotFound, isUnauthorized, isRateLimitedShortcuts for 404, 401 and 429
isTimeoutTrue when code is TIMEOUT: the client's time limit ran out, or the call was cancelled
isNetworkErrorTrue whenever status is 0, timeouts included

Retries happen before the error is thrown: by default up to 3 attempts for network errors, timeouts, 5xx and 429 answers. See retries & timeouts.

What the API returns

StatusWhenRetried
400A required parameter is missingNo
401The key is missing, doesn't start with pk_live_, isn't recognised, or was sent in the URLNo
402The business's plan has ended, and so have the 30 days its posts stay up afterwardsNo
404No published post with that slug, or the business was deletedNo
500Something failed on NexoFlow's sideYes

The Content API reference lists the same statuses for plain HTTP.

Errors before a request

A few mistakes are caught before anything is sent, and throw a plain Error rather than a NexoFlowError: a missing key or one that doesn't start with pk_live_, a bad timeout or retry value in the constructor, and an empty slug passed to nf.posts.get.