@open-captable-protocol/canton 0.2.150 → 0.2.152
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/errors/OcpContractError.d.ts +52 -0
- package/dist/errors/OcpContractError.d.ts.map +1 -0
- package/dist/errors/OcpContractError.js +45 -0
- package/dist/errors/OcpContractError.js.map +1 -0
- package/dist/errors/OcpError.d.ts +27 -0
- package/dist/errors/OcpError.d.ts.map +1 -0
- package/dist/errors/OcpError.js +33 -0
- package/dist/errors/OcpError.js.map +1 -0
- package/dist/errors/OcpNetworkError.d.ts +49 -0
- package/dist/errors/OcpNetworkError.d.ts.map +1 -0
- package/dist/errors/OcpNetworkError.js +45 -0
- package/dist/errors/OcpNetworkError.js.map +1 -0
- package/dist/errors/OcpParseError.d.ts +41 -0
- package/dist/errors/OcpParseError.d.ts.map +1 -0
- package/dist/errors/OcpParseError.js +40 -0
- package/dist/errors/OcpParseError.js.map +1 -0
- package/dist/errors/OcpValidationError.d.ts +49 -0
- package/dist/errors/OcpValidationError.d.ts.map +1 -0
- package/dist/errors/OcpValidationError.js +46 -0
- package/dist/errors/OcpValidationError.js.map +1 -0
- package/dist/errors/codes.d.ts +23 -0
- package/dist/errors/codes.d.ts.map +1 -0
- package/dist/errors/codes.js +29 -0
- package/dist/errors/codes.js.map +1 -0
- package/dist/errors/index.d.ts +48 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +59 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/functions/OpenCapTable/capTable/CapTableBatch.d.ts +2 -1
- package/dist/functions/OpenCapTable/capTable/CapTableBatch.d.ts.map +1 -1
- package/dist/functions/OpenCapTable/capTable/CapTableBatch.js +14 -4
- package/dist/functions/OpenCapTable/capTable/CapTableBatch.js.map +1 -1
- package/dist/functions/OpenCapTable/capTable/ocfToDaml.d.ts.map +1 -1
- package/dist/functions/OpenCapTable/capTable/ocfToDaml.js +151 -50
- package/dist/functions/OpenCapTable/capTable/ocfToDaml.js.map +1 -1
- package/dist/functions/OpenCapTable/issuer/createIssuer.d.ts.map +1 -1
- package/dist/functions/OpenCapTable/issuer/createIssuer.js +15 -4
- package/dist/functions/OpenCapTable/issuer/createIssuer.js.map +1 -1
- package/dist/functions/OpenCapTable/stakeholder/getStakeholderAsOcf.d.ts.map +1 -1
- package/dist/functions/OpenCapTable/stakeholder/getStakeholderAsOcf.js +21 -5
- package/dist/functions/OpenCapTable/stakeholder/getStakeholderAsOcf.js.map +1 -1
- package/dist/functions/OpenCapTable/stakeholder/stakeholderDataToDaml.d.ts.map +1 -1
- package/dist/functions/OpenCapTable/stakeholder/stakeholderDataToDaml.js +19 -5
- package/dist/functions/OpenCapTable/stakeholder/stakeholderDataToDaml.js.map +1 -1
- package/dist/functions/OpenCapTable/stockClass/stockClassDataToDaml.d.ts.map +1 -1
- package/dist/functions/OpenCapTable/stockClass/stockClassDataToDaml.js +11 -3
- package/dist/functions/OpenCapTable/stockClass/stockClassDataToDaml.js.map +1 -1
- package/dist/functions/OpenCapTable/stockIssuance/createStockIssuance.d.ts.map +1 -1
- package/dist/functions/OpenCapTable/stockIssuance/createStockIssuance.js +35 -11
- package/dist/functions/OpenCapTable/stockIssuance/createStockIssuance.js.map +1 -1
- package/dist/functions/OpenCapTable/stockRepurchase/stockRepurchaseDataToDaml.d.ts.map +1 -1
- package/dist/functions/OpenCapTable/stockRepurchase/stockRepurchaseDataToDaml.js +19 -6
- package/dist/functions/OpenCapTable/stockRepurchase/stockRepurchaseDataToDaml.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/typeConversions.d.ts +1 -1
- package/dist/utils/typeConversions.d.ts.map +1 -1
- package/dist/utils/typeConversions.js +23 -6
- package/dist/utils/typeConversions.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type OcpErrorCode } from './codes';
|
|
2
|
+
import { OcpError } from './OcpError';
|
|
3
|
+
export interface OcpContractErrorOptions {
|
|
4
|
+
/** The contract ID involved in the error */
|
|
5
|
+
contractId?: string;
|
|
6
|
+
/** The DAML template ID */
|
|
7
|
+
templateId?: string;
|
|
8
|
+
/** The choice being exercised when the error occurred */
|
|
9
|
+
choice?: string;
|
|
10
|
+
/** The original error that caused this error */
|
|
11
|
+
cause?: Error;
|
|
12
|
+
/** Specific contract error code (defaults to CHOICE_FAILED) */
|
|
13
|
+
code?: OcpErrorCode;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Errors from Canton/DAML contract interactions.
|
|
17
|
+
*
|
|
18
|
+
* Thrown when contract operations fail, such as exercising a choice,
|
|
19
|
+
* fetching contract data, or when expected results are not found in
|
|
20
|
+
* transaction trees.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* throw new OcpContractError('UpdateCapTable result not found in transaction tree', {
|
|
25
|
+
* contractId: capTableContractId,
|
|
26
|
+
* choice: 'UpdateCapTable',
|
|
27
|
+
* code: OcpErrorCodes.RESULT_NOT_FOUND,
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @example Catching contract errors
|
|
32
|
+
* ```typescript
|
|
33
|
+
* try {
|
|
34
|
+
* await ocp.OpenCapTable.capTable.update(...).execute();
|
|
35
|
+
* } catch (error) {
|
|
36
|
+
* if (error instanceof OcpContractError) {
|
|
37
|
+
* console.error(`Contract error on ${error.choice}: ${error.message}`);
|
|
38
|
+
* console.error(`Contract ID: ${error.contractId}`);
|
|
39
|
+
* }
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare class OcpContractError extends OcpError {
|
|
44
|
+
/** The contract ID involved in the error */
|
|
45
|
+
readonly contractId?: string;
|
|
46
|
+
/** The DAML template ID */
|
|
47
|
+
readonly templateId?: string;
|
|
48
|
+
/** The choice being exercised when the error occurred */
|
|
49
|
+
readonly choice?: string;
|
|
50
|
+
constructor(message: string, options?: OcpContractErrorOptions);
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=OcpContractError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OcpContractError.d.ts","sourceRoot":"","sources":["../../src/errors/OcpContractError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,WAAW,uBAAuB;IACtC,4CAA4C;IAC5C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2BAA2B;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yDAAyD;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,+DAA+D;IAC/D,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,gBAAiB,SAAQ,QAAQ;IAC5C,4CAA4C;IAC5C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAE7B,2BAA2B;IAC3B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAE7B,yDAAyD;IACzD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;gBAEb,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,uBAAuB;CAQ/D"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OcpContractError = void 0;
|
|
4
|
+
const codes_1 = require("./codes");
|
|
5
|
+
const OcpError_1 = require("./OcpError");
|
|
6
|
+
/**
|
|
7
|
+
* Errors from Canton/DAML contract interactions.
|
|
8
|
+
*
|
|
9
|
+
* Thrown when contract operations fail, such as exercising a choice,
|
|
10
|
+
* fetching contract data, or when expected results are not found in
|
|
11
|
+
* transaction trees.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* throw new OcpContractError('UpdateCapTable result not found in transaction tree', {
|
|
16
|
+
* contractId: capTableContractId,
|
|
17
|
+
* choice: 'UpdateCapTable',
|
|
18
|
+
* code: OcpErrorCodes.RESULT_NOT_FOUND,
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @example Catching contract errors
|
|
23
|
+
* ```typescript
|
|
24
|
+
* try {
|
|
25
|
+
* await ocp.OpenCapTable.capTable.update(...).execute();
|
|
26
|
+
* } catch (error) {
|
|
27
|
+
* if (error instanceof OcpContractError) {
|
|
28
|
+
* console.error(`Contract error on ${error.choice}: ${error.message}`);
|
|
29
|
+
* console.error(`Contract ID: ${error.contractId}`);
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
class OcpContractError extends OcpError_1.OcpError {
|
|
35
|
+
constructor(message, options) {
|
|
36
|
+
const code = options?.code ?? codes_1.OcpErrorCodes.CHOICE_FAILED;
|
|
37
|
+
super(message, code, options?.cause);
|
|
38
|
+
this.name = 'OcpContractError';
|
|
39
|
+
this.contractId = options?.contractId;
|
|
40
|
+
this.templateId = options?.templateId;
|
|
41
|
+
this.choice = options?.choice;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.OcpContractError = OcpContractError;
|
|
45
|
+
//# sourceMappingURL=OcpContractError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OcpContractError.js","sourceRoot":"","sources":["../../src/errors/OcpContractError.ts"],"names":[],"mappings":";;;AAAA,mCAA2D;AAC3D,yCAAsC;AAetC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAa,gBAAiB,SAAQ,mBAAQ;IAU5C,YAAY,OAAe,EAAE,OAAiC;QAC5D,MAAM,IAAI,GAAG,OAAO,EAAE,IAAI,IAAI,qBAAa,CAAC,aAAa,CAAC;QAC1D,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,UAAU,GAAG,OAAO,EAAE,UAAU,CAAC;QACtC,IAAI,CAAC,UAAU,GAAG,OAAO,EAAE,UAAU,CAAC;QACtC,IAAI,CAAC,MAAM,GAAG,OAAO,EAAE,MAAM,CAAC;IAChC,CAAC;CACF;AAlBD,4CAkBC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { OcpErrorCode } from './codes';
|
|
2
|
+
/**
|
|
3
|
+
* Base error class for all OCP SDK errors.
|
|
4
|
+
*
|
|
5
|
+
* Provides structured error information including an error code and optional cause.
|
|
6
|
+
* All OCP-specific errors extend this class, allowing consumers to catch all SDK
|
|
7
|
+
* errors with a single `catch (error instanceof OcpError)` check.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* try {
|
|
12
|
+
* await ocp.OpenCapTable.issuer.createIssuer(params);
|
|
13
|
+
* } catch (error) {
|
|
14
|
+
* if (error instanceof OcpError) {
|
|
15
|
+
* console.error(`OCP Error [${error.code}]: ${error.message}`);
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare class OcpError extends Error {
|
|
21
|
+
/** Error code for programmatic handling */
|
|
22
|
+
readonly code: OcpErrorCode;
|
|
23
|
+
/** The original error that caused this error, if any */
|
|
24
|
+
readonly cause?: Error;
|
|
25
|
+
constructor(message: string, code: OcpErrorCode, cause?: Error);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=OcpError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OcpError.d.ts","sourceRoot":"","sources":["../../src/errors/OcpError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,QAAS,SAAQ,KAAK;IACjC,2CAA2C;IAC3C,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAE5B,wDAAwD;IACxD,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;gBAEX,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,CAAC,EAAE,KAAK;CAS/D"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OcpError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Base error class for all OCP SDK errors.
|
|
6
|
+
*
|
|
7
|
+
* Provides structured error information including an error code and optional cause.
|
|
8
|
+
* All OCP-specific errors extend this class, allowing consumers to catch all SDK
|
|
9
|
+
* errors with a single `catch (error instanceof OcpError)` check.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* try {
|
|
14
|
+
* await ocp.OpenCapTable.issuer.createIssuer(params);
|
|
15
|
+
* } catch (error) {
|
|
16
|
+
* if (error instanceof OcpError) {
|
|
17
|
+
* console.error(`OCP Error [${error.code}]: ${error.message}`);
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
class OcpError extends Error {
|
|
23
|
+
constructor(message, code, cause) {
|
|
24
|
+
super(message);
|
|
25
|
+
this.name = 'OcpError';
|
|
26
|
+
this.code = code;
|
|
27
|
+
this.cause = cause;
|
|
28
|
+
// Maintain proper stack trace in V8 environments (Node.js, Chrome)
|
|
29
|
+
Error.captureStackTrace(this, this.constructor);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.OcpError = OcpError;
|
|
33
|
+
//# sourceMappingURL=OcpError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OcpError.js","sourceRoot":"","sources":["../../src/errors/OcpError.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAa,QAAS,SAAQ,KAAK;IAOjC,YAAY,OAAe,EAAE,IAAkB,EAAE,KAAa;QAC5D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QAEnB,mEAAmE;QACnE,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAClD,CAAC;CACF;AAhBD,4BAgBC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type OcpErrorCode } from './codes';
|
|
2
|
+
import { OcpError } from './OcpError';
|
|
3
|
+
export interface OcpNetworkErrorOptions {
|
|
4
|
+
/** The endpoint that was being accessed */
|
|
5
|
+
endpoint?: string;
|
|
6
|
+
/** The HTTP status code, if applicable */
|
|
7
|
+
statusCode?: number;
|
|
8
|
+
/** The original error that caused this error */
|
|
9
|
+
cause?: Error;
|
|
10
|
+
/** Specific network error code (defaults to CONNECTION_FAILED) */
|
|
11
|
+
code?: OcpErrorCode;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Network or connectivity errors.
|
|
15
|
+
*
|
|
16
|
+
* Thrown when network operations fail, such as connection failures,
|
|
17
|
+
* timeouts, or rate limiting.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* throw new OcpNetworkError('Failed to connect to Canton JSON API', {
|
|
22
|
+
* endpoint: 'http://localhost:3975',
|
|
23
|
+
* code: OcpErrorCodes.CONNECTION_FAILED,
|
|
24
|
+
* cause: originalError,
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @example Catching network errors
|
|
29
|
+
* ```typescript
|
|
30
|
+
* try {
|
|
31
|
+
* await ocp.OpenCapTable.issuer.getIssuerAsOcf(params);
|
|
32
|
+
* } catch (error) {
|
|
33
|
+
* if (error instanceof OcpNetworkError) {
|
|
34
|
+
* console.error(`Network error: ${error.message}`);
|
|
35
|
+
* if (error.statusCode === 503) {
|
|
36
|
+
* console.error('Service unavailable - retry later');
|
|
37
|
+
* }
|
|
38
|
+
* }
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare class OcpNetworkError extends OcpError {
|
|
43
|
+
/** The endpoint that was being accessed */
|
|
44
|
+
readonly endpoint?: string;
|
|
45
|
+
/** The HTTP status code, if applicable */
|
|
46
|
+
readonly statusCode?: number;
|
|
47
|
+
constructor(message: string, options?: OcpNetworkErrorOptions);
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=OcpNetworkError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OcpNetworkError.d.ts","sourceRoot":"","sources":["../../src/errors/OcpNetworkError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,WAAW,sBAAsB;IACrC,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0CAA0C;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gDAAgD;IAChD,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,kEAAkE;IAClE,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,eAAgB,SAAQ,QAAQ;IAC3C,2CAA2C;IAC3C,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAE3B,0CAA0C;IAC1C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;gBAEjB,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,sBAAsB;CAO9D"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OcpNetworkError = void 0;
|
|
4
|
+
const codes_1 = require("./codes");
|
|
5
|
+
const OcpError_1 = require("./OcpError");
|
|
6
|
+
/**
|
|
7
|
+
* Network or connectivity errors.
|
|
8
|
+
*
|
|
9
|
+
* Thrown when network operations fail, such as connection failures,
|
|
10
|
+
* timeouts, or rate limiting.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* throw new OcpNetworkError('Failed to connect to Canton JSON API', {
|
|
15
|
+
* endpoint: 'http://localhost:3975',
|
|
16
|
+
* code: OcpErrorCodes.CONNECTION_FAILED,
|
|
17
|
+
* cause: originalError,
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @example Catching network errors
|
|
22
|
+
* ```typescript
|
|
23
|
+
* try {
|
|
24
|
+
* await ocp.OpenCapTable.issuer.getIssuerAsOcf(params);
|
|
25
|
+
* } catch (error) {
|
|
26
|
+
* if (error instanceof OcpNetworkError) {
|
|
27
|
+
* console.error(`Network error: ${error.message}`);
|
|
28
|
+
* if (error.statusCode === 503) {
|
|
29
|
+
* console.error('Service unavailable - retry later');
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
class OcpNetworkError extends OcpError_1.OcpError {
|
|
36
|
+
constructor(message, options) {
|
|
37
|
+
const code = options?.code ?? codes_1.OcpErrorCodes.CONNECTION_FAILED;
|
|
38
|
+
super(message, code, options?.cause);
|
|
39
|
+
this.name = 'OcpNetworkError';
|
|
40
|
+
this.endpoint = options?.endpoint;
|
|
41
|
+
this.statusCode = options?.statusCode;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.OcpNetworkError = OcpNetworkError;
|
|
45
|
+
//# sourceMappingURL=OcpNetworkError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OcpNetworkError.js","sourceRoot":"","sources":["../../src/errors/OcpNetworkError.ts"],"names":[],"mappings":";;;AAAA,mCAA2D;AAC3D,yCAAsC;AAatC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAa,eAAgB,SAAQ,mBAAQ;IAO3C,YAAY,OAAe,EAAE,OAAgC;QAC3D,MAAM,IAAI,GAAG,OAAO,EAAE,IAAI,IAAI,qBAAa,CAAC,iBAAiB,CAAC;QAC9D,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,QAAQ,GAAG,OAAO,EAAE,QAAQ,CAAC;QAClC,IAAI,CAAC,UAAU,GAAG,OAAO,EAAE,UAAU,CAAC;IACxC,CAAC;CACF;AAdD,0CAcC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type OcpErrorCode } from './codes';
|
|
2
|
+
import { OcpError } from './OcpError';
|
|
3
|
+
export interface OcpParseErrorOptions {
|
|
4
|
+
/** Description of the data source being parsed */
|
|
5
|
+
source?: string;
|
|
6
|
+
/** The original error that caused this error */
|
|
7
|
+
cause?: Error;
|
|
8
|
+
/** Specific parse error code (defaults to INVALID_RESPONSE) */
|
|
9
|
+
code?: OcpErrorCode;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Errors from parsing or transforming data.
|
|
13
|
+
*
|
|
14
|
+
* Thrown when data cannot be parsed or transformed, such as invalid
|
|
15
|
+
* DAML responses, unknown enum values, or schema mismatches.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* throw new OcpParseError('Unknown DAML stakeholder type: InvalidType', {
|
|
20
|
+
* source: 'stakeholder.stakeholder_type',
|
|
21
|
+
* code: OcpErrorCodes.UNKNOWN_ENUM_VALUE,
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @example Catching parse errors
|
|
26
|
+
* ```typescript
|
|
27
|
+
* try {
|
|
28
|
+
* const result = await ocp.OpenCapTable.stakeholder.getStakeholderAsOcf(params);
|
|
29
|
+
* } catch (error) {
|
|
30
|
+
* if (error instanceof OcpParseError) {
|
|
31
|
+
* console.error(`Parse error in ${error.source}: ${error.message}`);
|
|
32
|
+
* }
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare class OcpParseError extends OcpError {
|
|
37
|
+
/** Description of the data source being parsed */
|
|
38
|
+
readonly source?: string;
|
|
39
|
+
constructor(message: string, options?: OcpParseErrorOptions);
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=OcpParseError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OcpParseError.d.ts","sourceRoot":"","sources":["../../src/errors/OcpParseError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,WAAW,oBAAoB;IACnC,kDAAkD;IAClD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,+DAA+D;IAC/D,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,aAAc,SAAQ,QAAQ;IACzC,kDAAkD;IAClD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;gBAEb,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB;CAM5D"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OcpParseError = void 0;
|
|
4
|
+
const codes_1 = require("./codes");
|
|
5
|
+
const OcpError_1 = require("./OcpError");
|
|
6
|
+
/**
|
|
7
|
+
* Errors from parsing or transforming data.
|
|
8
|
+
*
|
|
9
|
+
* Thrown when data cannot be parsed or transformed, such as invalid
|
|
10
|
+
* DAML responses, unknown enum values, or schema mismatches.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* throw new OcpParseError('Unknown DAML stakeholder type: InvalidType', {
|
|
15
|
+
* source: 'stakeholder.stakeholder_type',
|
|
16
|
+
* code: OcpErrorCodes.UNKNOWN_ENUM_VALUE,
|
|
17
|
+
* });
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @example Catching parse errors
|
|
21
|
+
* ```typescript
|
|
22
|
+
* try {
|
|
23
|
+
* const result = await ocp.OpenCapTable.stakeholder.getStakeholderAsOcf(params);
|
|
24
|
+
* } catch (error) {
|
|
25
|
+
* if (error instanceof OcpParseError) {
|
|
26
|
+
* console.error(`Parse error in ${error.source}: ${error.message}`);
|
|
27
|
+
* }
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
class OcpParseError extends OcpError_1.OcpError {
|
|
32
|
+
constructor(message, options) {
|
|
33
|
+
const code = options?.code ?? codes_1.OcpErrorCodes.INVALID_RESPONSE;
|
|
34
|
+
super(message, code, options?.cause);
|
|
35
|
+
this.name = 'OcpParseError';
|
|
36
|
+
this.source = options?.source;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.OcpParseError = OcpParseError;
|
|
40
|
+
//# sourceMappingURL=OcpParseError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OcpParseError.js","sourceRoot":"","sources":["../../src/errors/OcpParseError.ts"],"names":[],"mappings":";;;AAAA,mCAA2D;AAC3D,yCAAsC;AAWtC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAa,aAAc,SAAQ,mBAAQ;IAIzC,YAAY,OAAe,EAAE,OAA8B;QACzD,MAAM,IAAI,GAAG,OAAO,EAAE,IAAI,IAAI,qBAAa,CAAC,gBAAgB,CAAC;QAC7D,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,OAAO,EAAE,MAAM,CAAC;IAChC,CAAC;CACF;AAVD,sCAUC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type OcpErrorCode } from './codes';
|
|
2
|
+
import { OcpError } from './OcpError';
|
|
3
|
+
export interface OcpValidationErrorOptions {
|
|
4
|
+
/** The expected type for this field */
|
|
5
|
+
expectedType?: string;
|
|
6
|
+
/** The actual value received */
|
|
7
|
+
receivedValue?: unknown;
|
|
8
|
+
/** Specific validation error code (defaults to REQUIRED_FIELD_MISSING) */
|
|
9
|
+
code?: OcpErrorCode;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Validation errors for invalid input data.
|
|
13
|
+
*
|
|
14
|
+
* Thrown when input data fails validation before being sent to DAML contracts.
|
|
15
|
+
* Includes the field path where validation failed and optionally the expected
|
|
16
|
+
* type and received value.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* if (!data.id) {
|
|
21
|
+
* throw new OcpValidationError('stakeholder.id', 'Required field is missing or empty', {
|
|
22
|
+
* expectedType: 'string',
|
|
23
|
+
* receivedValue: data.id,
|
|
24
|
+
* });
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @example Catching validation errors
|
|
29
|
+
* ```typescript
|
|
30
|
+
* try {
|
|
31
|
+
* await ocp.OpenCapTable.capTable.update(...).create('stakeholder', data).execute();
|
|
32
|
+
* } catch (error) {
|
|
33
|
+
* if (error instanceof OcpValidationError) {
|
|
34
|
+
* console.error(`Validation failed at '${error.fieldPath}': ${error.message}`);
|
|
35
|
+
* console.error(`Expected: ${error.expectedType}, Got: ${error.receivedValue}`);
|
|
36
|
+
* }
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare class OcpValidationError extends OcpError {
|
|
41
|
+
/** The dot-separated path to the field that failed validation */
|
|
42
|
+
readonly fieldPath: string;
|
|
43
|
+
/** The expected type for this field, if applicable */
|
|
44
|
+
readonly expectedType?: string;
|
|
45
|
+
/** The actual value that was received */
|
|
46
|
+
readonly receivedValue?: unknown;
|
|
47
|
+
constructor(fieldPath: string, message: string, options?: OcpValidationErrorOptions);
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=OcpValidationError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OcpValidationError.d.ts","sourceRoot":"","sources":["../../src/errors/OcpValidationError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,WAAW,yBAAyB;IACxC,uCAAuC;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gCAAgC;IAChC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,0EAA0E;IAC1E,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,kBAAmB,SAAQ,QAAQ;IAC9C,iEAAiE;IACjE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B,sDAAsD;IACtD,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAE/B,yCAAyC;IACzC,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;gBAErB,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,yBAAyB;CAQpF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OcpValidationError = void 0;
|
|
4
|
+
const codes_1 = require("./codes");
|
|
5
|
+
const OcpError_1 = require("./OcpError");
|
|
6
|
+
/**
|
|
7
|
+
* Validation errors for invalid input data.
|
|
8
|
+
*
|
|
9
|
+
* Thrown when input data fails validation before being sent to DAML contracts.
|
|
10
|
+
* Includes the field path where validation failed and optionally the expected
|
|
11
|
+
* type and received value.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* if (!data.id) {
|
|
16
|
+
* throw new OcpValidationError('stakeholder.id', 'Required field is missing or empty', {
|
|
17
|
+
* expectedType: 'string',
|
|
18
|
+
* receivedValue: data.id,
|
|
19
|
+
* });
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @example Catching validation errors
|
|
24
|
+
* ```typescript
|
|
25
|
+
* try {
|
|
26
|
+
* await ocp.OpenCapTable.capTable.update(...).create('stakeholder', data).execute();
|
|
27
|
+
* } catch (error) {
|
|
28
|
+
* if (error instanceof OcpValidationError) {
|
|
29
|
+
* console.error(`Validation failed at '${error.fieldPath}': ${error.message}`);
|
|
30
|
+
* console.error(`Expected: ${error.expectedType}, Got: ${error.receivedValue}`);
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
class OcpValidationError extends OcpError_1.OcpError {
|
|
36
|
+
constructor(fieldPath, message, options) {
|
|
37
|
+
const code = options?.code ?? codes_1.OcpErrorCodes.REQUIRED_FIELD_MISSING;
|
|
38
|
+
super(`Validation error at '${fieldPath}': ${message}`, code);
|
|
39
|
+
this.name = 'OcpValidationError';
|
|
40
|
+
this.fieldPath = fieldPath;
|
|
41
|
+
this.expectedType = options?.expectedType;
|
|
42
|
+
this.receivedValue = options?.receivedValue;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.OcpValidationError = OcpValidationError;
|
|
46
|
+
//# sourceMappingURL=OcpValidationError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OcpValidationError.js","sourceRoot":"","sources":["../../src/errors/OcpValidationError.ts"],"names":[],"mappings":";;;AAAA,mCAA2D;AAC3D,yCAAsC;AAWtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAa,kBAAmB,SAAQ,mBAAQ;IAU9C,YAAY,SAAiB,EAAE,OAAe,EAAE,OAAmC;QACjF,MAAM,IAAI,GAAG,OAAO,EAAE,IAAI,IAAI,qBAAa,CAAC,sBAAsB,CAAC;QACnE,KAAK,CAAC,wBAAwB,SAAS,MAAM,OAAO,EAAE,EAAE,IAAI,CAAC,CAAC;QAC9D,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,YAAY,GAAG,OAAO,EAAE,YAAY,CAAC;QAC1C,IAAI,CAAC,aAAa,GAAG,OAAO,EAAE,aAAa,CAAC;IAC9C,CAAC;CACF;AAlBD,gDAkBC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error codes for OCP SDK errors.
|
|
3
|
+
*
|
|
4
|
+
* These codes allow programmatic handling of specific error conditions.
|
|
5
|
+
*/
|
|
6
|
+
export declare const OcpErrorCodes: {
|
|
7
|
+
readonly REQUIRED_FIELD_MISSING: "REQUIRED_FIELD_MISSING";
|
|
8
|
+
readonly INVALID_TYPE: "INVALID_TYPE";
|
|
9
|
+
readonly INVALID_FORMAT: "INVALID_FORMAT";
|
|
10
|
+
readonly OUT_OF_RANGE: "OUT_OF_RANGE";
|
|
11
|
+
readonly CONTRACT_NOT_FOUND: "CONTRACT_NOT_FOUND";
|
|
12
|
+
readonly CHOICE_FAILED: "CHOICE_FAILED";
|
|
13
|
+
readonly AUTHORIZATION_FAILED: "AUTHORIZATION_FAILED";
|
|
14
|
+
readonly RESULT_NOT_FOUND: "RESULT_NOT_FOUND";
|
|
15
|
+
readonly CONNECTION_FAILED: "CONNECTION_FAILED";
|
|
16
|
+
readonly TIMEOUT: "TIMEOUT";
|
|
17
|
+
readonly RATE_LIMITED: "RATE_LIMITED";
|
|
18
|
+
readonly INVALID_RESPONSE: "INVALID_RESPONSE";
|
|
19
|
+
readonly SCHEMA_MISMATCH: "SCHEMA_MISMATCH";
|
|
20
|
+
readonly UNKNOWN_ENUM_VALUE: "UNKNOWN_ENUM_VALUE";
|
|
21
|
+
};
|
|
22
|
+
export type OcpErrorCode = (typeof OcpErrorCodes)[keyof typeof OcpErrorCodes];
|
|
23
|
+
//# sourceMappingURL=codes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codes.d.ts","sourceRoot":"","sources":["../../src/errors/codes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;CAsBhB,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OcpErrorCodes = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Error codes for OCP SDK errors.
|
|
6
|
+
*
|
|
7
|
+
* These codes allow programmatic handling of specific error conditions.
|
|
8
|
+
*/
|
|
9
|
+
exports.OcpErrorCodes = {
|
|
10
|
+
// Validation errors
|
|
11
|
+
REQUIRED_FIELD_MISSING: 'REQUIRED_FIELD_MISSING',
|
|
12
|
+
INVALID_TYPE: 'INVALID_TYPE',
|
|
13
|
+
INVALID_FORMAT: 'INVALID_FORMAT',
|
|
14
|
+
OUT_OF_RANGE: 'OUT_OF_RANGE',
|
|
15
|
+
// Contract errors
|
|
16
|
+
CONTRACT_NOT_FOUND: 'CONTRACT_NOT_FOUND',
|
|
17
|
+
CHOICE_FAILED: 'CHOICE_FAILED',
|
|
18
|
+
AUTHORIZATION_FAILED: 'AUTHORIZATION_FAILED',
|
|
19
|
+
RESULT_NOT_FOUND: 'RESULT_NOT_FOUND',
|
|
20
|
+
// Network errors
|
|
21
|
+
CONNECTION_FAILED: 'CONNECTION_FAILED',
|
|
22
|
+
TIMEOUT: 'TIMEOUT',
|
|
23
|
+
RATE_LIMITED: 'RATE_LIMITED',
|
|
24
|
+
// Parse errors
|
|
25
|
+
INVALID_RESPONSE: 'INVALID_RESPONSE',
|
|
26
|
+
SCHEMA_MISMATCH: 'SCHEMA_MISMATCH',
|
|
27
|
+
UNKNOWN_ENUM_VALUE: 'UNKNOWN_ENUM_VALUE',
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=codes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codes.js","sourceRoot":"","sources":["../../src/errors/codes.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACU,QAAA,aAAa,GAAG;IAC3B,oBAAoB;IACpB,sBAAsB,EAAE,wBAAwB;IAChD,YAAY,EAAE,cAAc;IAC5B,cAAc,EAAE,gBAAgB;IAChC,YAAY,EAAE,cAAc;IAE5B,kBAAkB;IAClB,kBAAkB,EAAE,oBAAoB;IACxC,aAAa,EAAE,eAAe;IAC9B,oBAAoB,EAAE,sBAAsB;IAC5C,gBAAgB,EAAE,kBAAkB;IAEpC,iBAAiB;IACjB,iBAAiB,EAAE,mBAAmB;IACtC,OAAO,EAAE,SAAS;IAClB,YAAY,EAAE,cAAc;IAE5B,eAAe;IACf,gBAAgB,EAAE,kBAAkB;IACpC,eAAe,EAAE,iBAAiB;IAClC,kBAAkB,EAAE,oBAAoB;CAChC,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured error types for the OCP SDK.
|
|
3
|
+
*
|
|
4
|
+
* This module provides a hierarchy of error types for different failure modes,
|
|
5
|
+
* enabling better error handling, debugging, and developer experience.
|
|
6
|
+
*
|
|
7
|
+
* @example Error handling
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import {
|
|
10
|
+
* OcpError,
|
|
11
|
+
* OcpValidationError,
|
|
12
|
+
* OcpContractError,
|
|
13
|
+
* OcpNetworkError,
|
|
14
|
+
* OcpParseError,
|
|
15
|
+
* OcpErrorCodes,
|
|
16
|
+
* } from '@open-captable-protocol/canton';
|
|
17
|
+
*
|
|
18
|
+
* try {
|
|
19
|
+
* await ocp.OpenCapTable.capTable.update(params).create('stakeholder', data).execute();
|
|
20
|
+
* } catch (error) {
|
|
21
|
+
* if (error instanceof OcpValidationError) {
|
|
22
|
+
* // Handle validation errors (invalid input)
|
|
23
|
+
* console.error(`Invalid input at ${error.fieldPath}: ${error.message}`);
|
|
24
|
+
* } else if (error instanceof OcpContractError) {
|
|
25
|
+
* // Handle contract errors (DAML/Canton issues)
|
|
26
|
+
* console.error(`Contract error on ${error.choice}: ${error.message}`);
|
|
27
|
+
* } else if (error instanceof OcpNetworkError) {
|
|
28
|
+
* // Handle network errors (connectivity issues)
|
|
29
|
+
* console.error(`Network error: ${error.message}`);
|
|
30
|
+
* } else if (error instanceof OcpParseError) {
|
|
31
|
+
* // Handle parse errors (data transformation issues)
|
|
32
|
+
* console.error(`Parse error: ${error.message}`);
|
|
33
|
+
* } else if (error instanceof OcpError) {
|
|
34
|
+
* // Handle any other OCP errors
|
|
35
|
+
* console.error(`OCP Error [${error.code}]: ${error.message}`);
|
|
36
|
+
* } else {
|
|
37
|
+
* throw error; // Re-throw unknown errors
|
|
38
|
+
* }
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export { OcpErrorCodes, type OcpErrorCode } from './codes';
|
|
43
|
+
export { OcpContractError, type OcpContractErrorOptions } from './OcpContractError';
|
|
44
|
+
export { OcpError } from './OcpError';
|
|
45
|
+
export { OcpNetworkError, type OcpNetworkErrorOptions } from './OcpNetworkError';
|
|
46
|
+
export { OcpParseError, type OcpParseErrorOptions } from './OcpParseError';
|
|
47
|
+
export { OcpValidationError, type OcpValidationErrorOptions } from './OcpValidationError';
|
|
48
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAGH,OAAO,EAAE,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAG3D,OAAO,EAAE,gBAAgB,EAAE,KAAK,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AACpF,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,KAAK,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,KAAK,yBAAyB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Structured error types for the OCP SDK.
|
|
4
|
+
*
|
|
5
|
+
* This module provides a hierarchy of error types for different failure modes,
|
|
6
|
+
* enabling better error handling, debugging, and developer experience.
|
|
7
|
+
*
|
|
8
|
+
* @example Error handling
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import {
|
|
11
|
+
* OcpError,
|
|
12
|
+
* OcpValidationError,
|
|
13
|
+
* OcpContractError,
|
|
14
|
+
* OcpNetworkError,
|
|
15
|
+
* OcpParseError,
|
|
16
|
+
* OcpErrorCodes,
|
|
17
|
+
* } from '@open-captable-protocol/canton';
|
|
18
|
+
*
|
|
19
|
+
* try {
|
|
20
|
+
* await ocp.OpenCapTable.capTable.update(params).create('stakeholder', data).execute();
|
|
21
|
+
* } catch (error) {
|
|
22
|
+
* if (error instanceof OcpValidationError) {
|
|
23
|
+
* // Handle validation errors (invalid input)
|
|
24
|
+
* console.error(`Invalid input at ${error.fieldPath}: ${error.message}`);
|
|
25
|
+
* } else if (error instanceof OcpContractError) {
|
|
26
|
+
* // Handle contract errors (DAML/Canton issues)
|
|
27
|
+
* console.error(`Contract error on ${error.choice}: ${error.message}`);
|
|
28
|
+
* } else if (error instanceof OcpNetworkError) {
|
|
29
|
+
* // Handle network errors (connectivity issues)
|
|
30
|
+
* console.error(`Network error: ${error.message}`);
|
|
31
|
+
* } else if (error instanceof OcpParseError) {
|
|
32
|
+
* // Handle parse errors (data transformation issues)
|
|
33
|
+
* console.error(`Parse error: ${error.message}`);
|
|
34
|
+
* } else if (error instanceof OcpError) {
|
|
35
|
+
* // Handle any other OCP errors
|
|
36
|
+
* console.error(`OCP Error [${error.code}]: ${error.message}`);
|
|
37
|
+
* } else {
|
|
38
|
+
* throw error; // Re-throw unknown errors
|
|
39
|
+
* }
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
+
exports.OcpValidationError = exports.OcpParseError = exports.OcpNetworkError = exports.OcpError = exports.OcpContractError = exports.OcpErrorCodes = void 0;
|
|
45
|
+
// Error codes
|
|
46
|
+
var codes_1 = require("./codes");
|
|
47
|
+
Object.defineProperty(exports, "OcpErrorCodes", { enumerable: true, get: function () { return codes_1.OcpErrorCodes; } });
|
|
48
|
+
// Error classes
|
|
49
|
+
var OcpContractError_1 = require("./OcpContractError");
|
|
50
|
+
Object.defineProperty(exports, "OcpContractError", { enumerable: true, get: function () { return OcpContractError_1.OcpContractError; } });
|
|
51
|
+
var OcpError_1 = require("./OcpError");
|
|
52
|
+
Object.defineProperty(exports, "OcpError", { enumerable: true, get: function () { return OcpError_1.OcpError; } });
|
|
53
|
+
var OcpNetworkError_1 = require("./OcpNetworkError");
|
|
54
|
+
Object.defineProperty(exports, "OcpNetworkError", { enumerable: true, get: function () { return OcpNetworkError_1.OcpNetworkError; } });
|
|
55
|
+
var OcpParseError_1 = require("./OcpParseError");
|
|
56
|
+
Object.defineProperty(exports, "OcpParseError", { enumerable: true, get: function () { return OcpParseError_1.OcpParseError; } });
|
|
57
|
+
var OcpValidationError_1 = require("./OcpValidationError");
|
|
58
|
+
Object.defineProperty(exports, "OcpValidationError", { enumerable: true, get: function () { return OcpValidationError_1.OcpValidationError; } });
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;;;AAEH,cAAc;AACd,iCAA2D;AAAlD,sGAAA,aAAa,OAAA;AAEtB,gBAAgB;AAChB,uDAAoF;AAA3E,oHAAA,gBAAgB,OAAA;AACzB,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,qDAAiF;AAAxE,kHAAA,eAAe,OAAA;AACxB,iDAA2E;AAAlE,8GAAA,aAAa,OAAA;AACtB,2DAA0F;AAAjF,wHAAA,kBAAkB,OAAA"}
|