Skip to content

Errors ​

Which error you caught tells you where the problem is before you read the message.

ts
import { EvalwrightApiError, EvalwrightClientError } from "@evalwright/sdk";

try {
  await client.prompts.resolve(SUPPORT_REPLY_ID, { vars });
} catch (err) {
  if (err instanceof EvalwrightApiError) {
    // The server answered, and the answer was a refusal.
    console.error(err.status, err.code, err.message, err.details);
  } else if (err instanceof EvalwrightClientError) {
    // The call never left your process: the client was built wrong.
  } else {
    // Network, DNS, timeout, abort — the platform's own errors, unwrapped.
  }
}

EvalwrightApiError ​

PropertyType
statusnumberHTTP status
codestringStable machine-readable code — branch on this, not on the message
messagestringHuman-readable explanation
detailsunknownPresent when the server can say more
StatusCodeMeaningRetry?
401UNAUTHORIZEDKey missing, malformed or revokedNo
404NOT_FOUNDNothing is deployed for that prompt id in the key's environment — or the prompt's name was passed where its id goesNo
429, 5xx—Rate limited or upstream faultYes, with backoff

404 does not separate "no such prompt" from "not deployed here": saying which would tell a caller about prompts outside the environment its key reads.

EvalwrightClientError ​

Raised in your process, never by the server:

  • the client was constructed without an apiKey or baseUrl, with a negative cache.ttlMs, or with a timeoutMs that is not a whole number of milliseconds from 1 to 2147483647;
  • a resolve() call left out a variable the prompt needs or gave one that is not a string, or the prompt holds a malformed placeholder. The message names every one.

Retrying cannot help — fix the call.

Released under the MIT licence.