Skip to content

Reference

SDK errors — OcpError hierarchy

Structured errors (OcpValidationError, OcpContractError, OcpNetworkError, OcpParseError) under OcpError with OcpErrorCodes; plus non-Ocp helpers for CouponMinter waits and branded id conversion.

All Ocp* classes extend OcpError, which carries a string code from OcpErrorCodes, optional cause, classification, and context. Catch instanceof OcpError for unified handling, then narrow to subclasses for field paths, contract metadata, HTTP hints, or parse sources.

Hierarchy

ClassWhen thrownNotable fields
OcpValidationErrorInput fails before ledger (batch, network, payload shapes)fieldPath, expectedType, receivedValue; default code REQUIRED_FIELD_MISSING unless overridden
OcpContractErrorDAML/ledger contract operations, missing CreatedTreeEvent, diagnosed read failurescontractId, templateId, choice; default CHOICE_FAILED
OcpNetworkErrorConnectivity / HTTP failuresendpoint, statusCode; default CONNECTION_FAILED
OcpParseErrorSchema / enum / transform mismatchessource; default INVALID_RESPONSE

OcpErrorCodes (subset)

REQUIRED_FIELD_MISSING, INVALID_TYPE, INVALID_FORMAT, OUT_OF_RANGE, CONTRACT_NOT_FOUND, CHOICE_FAILED, AUTHORIZATION_FAILED, RESULT_NOT_FOUND, CONNECTION_FAILED, TIMEOUT, RATE_LIMITED, INVALID_RESPONSE, SCHEMA_MISMATCH, UNKNOWN_ENUM_VALUE, UNKNOWN_ENTITY_TYPE.

Examples

import { OcpError, OcpValidationError, OcpContractError } from '@open-captable-protocol/canton';

try {
  await ocp.OpenCapTableReports.companyValuationReport.create(params);
} catch (e) {
  if (e instanceof OcpValidationError) {
    console.error(e.fieldPath, e.receivedValue);
  } else if (e instanceof OcpContractError) {
    console.error(e.choice, e.contractId, e.code);
  } else if (e instanceof OcpError) {
    console.error(e.code, e.context);
  }
}
  • WaitAbortedError, WaitTimeoutErrorCouponMinter.waitUntilCanMint / mintWithRateLimit (Error subclasses).
  • toContractId / toPartyId / toOcfId / toSecurityId — throw plain Error when empty/invalid (see branded types).

See also

Source