Open Cap Table Protocol Canton SDK - v0.2.224
    Preparing search index...

    Type Alias OcpErrorCode

    OcpErrorCode: typeof OcpErrorCodes[keyof typeof OcpErrorCodes]

    Structured error types for the OCP SDK.

    This module provides a hierarchy of error types for different failure modes, enabling better error handling, debugging, and developer experience.

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

    try {
    await ocp.OpenCapTable.capTable.update(params).create('stakeholder', data).execute();
    } catch (error) {
    if (error instanceof OcpValidationError) {
    // Handle validation errors (invalid input)
    console.error(`Invalid input at ${error.fieldPath}: ${error.message}`);
    } else if (error instanceof OcpContractError) {
    // Handle contract errors (DAML/Canton issues)
    console.error(`Contract error on ${error.choice}: ${error.message}`);
    } else if (error instanceof OcpNetworkError) {
    // Handle network errors (connectivity issues)
    console.error(`Network error: ${error.message}`);
    } else if (error instanceof OcpParseError) {
    // Handle parse errors (data transformation issues)
    console.error(`Parse error: ${error.message}`);
    } else if (error instanceof OcpError) {
    // Handle any other OCP errors
    console.error(`OCP Error [${error.code}]: ${error.message}`);
    } else {
    throw error; // Re-throw unknown errors
    }
    }