Novant

Documentation

Sign in

Error Handling

Any error returned by the Novant API throws a NovantError. The error exposes status for the HTTP status code, message for a human-readable description of the error, and body for the parsed error response.

import { NovantClient, NovantError } from "@novant/sdk";

const client = new NovantClient({ apiKey: "ak_xxx" });

try {
  await client.project();
} catch (err) {
  if (err instanceof NovantError) {
    console.log(err.status);    // ex: 403
    console.log(err.message);   // ex: "Invalid API key."
  }
}

Network failures and timeouts are not API errors, and throw the underlying fetch error instead. Requests that exceed the client timeout throw a TimeoutError.

See API Errors for a full list of error codes, and Key Errors for errors specific to project and organization keys.