Skip to Content

Errors

PalantirApiError and ActionValidationError, the error classes thrown by @osdk/client.

import { ActionValidationError, PalantirApiError } from "@osdk/client";

class PalantirApiError extends Error {
  errorName?: string;
  errorCode?: string;
  errorDescription?: string;
  statusCode?: number;
  errorInstanceId?: string;
  parameters?: any;
}

class ActionValidationError extends Error {
  validation: ActionValidationResponse;
}

Requests that Foundry rejects throw PalantirApiError. Network failures and responses that are not JSON also throw a PalantirApiError, with no errorCode and the underlying error on cause. If your token provider throws, the client rethrows a plain Error. applyAction throws ActionValidationError when the server reports the parameters as INVALID; with $validateOnly: true it returns the validation response instead. Check with instanceof.

PalantirApiError

The class has no JSDoc and inherits Error fields, so this table is written by hand.

FieldTypeDescription
messagestringA readable summary of the error.
errorNamestring | undefinedThe Foundry error name, such as ObjectNotFound.
errorCodestring | undefinedThe error category, such as NOT_FOUND or PERMISSION_DENIED.
errorDescriptionstring | undefinedA longer description from the server.
statusCodenumber | undefinedThe HTTP status code.
errorInstanceIdstring | undefinedAn ID for this occurrence. Include it when you report an issue to Palantir support.
parametersanyError-specific details, such as the primary key that was not found.

ActionValidationError

FieldTypeDescription
messagestring"Validation Error: " followed by the validation response as JSON.
validation.result"VALID" | "INVALID"The overall result.
validation.submissionCriteriaSubmissionCriteriaEvaluation[]Each submission criterion and whether it passed.
validation.parametersRecord<string, ParameterEvaluationResult>The evaluation of each parameter, by parameter ID.

Example

src/promote.ts
import { Employee, modifyEmployee } from "@my-app/sdk";
import { ActionValidationError, PalantirApiError, type Client } from "@osdk/client";

export async function promote(client: Client, employeeId: number) {
  try {
    const employee = await client(Employee).fetchOne(employeeId);
    await client(modifyEmployee).applyAction({ employee, jobTitle: "Lead" });
  } catch (e) {
    if (e instanceof ActionValidationError) {
      return { ok: false, reason: e.validation.result };
    }
    if (e instanceof PalantirApiError) {
      return { ok: false, reason: `${e.errorName ?? "Error"} (${e.statusCode})` };
    }
    throw e;
  }
  return { ok: true };
}

See also

On this page