MCPcopy Index your code
hub / github.com/subquery/subql / parseContractError

Function parseContractError

packages/cli/src/controller/network/contract-errors.ts:22–43  ·  view source on GitHub ↗
(
  overwriteError: Partial<Record<ContractErrorCode, () => Promise<string> | string>>
)

Source from the content-addressed store, hash-verified

20 * You can provide an optional mapping of ContractErrorCode to custom error messages.
21 */
22export function parseContractError(
23 overwriteError: Partial<Record<ContractErrorCode, () => Promise<string> | string>>
24): (rawError: any) => Promise<never> {
25 return async (rawError: any) => {
26 const cErr = mapContractError(rawError);
27 const getOverwriteMessage = overwriteError[cErr.revertCode as ContractErrorCode];
28 if (getOverwriteMessage) {
29 let message = cErr.message;
30 try {
31 message = await getOverwriteMessage();
32 } catch (e) {
33 // Do nothing
34 }
35
36 throw new Error(message, {cause: rawError});
37 }
38 if (cErr.message) {
39 throw new Error(cErr.message, {cause: rawError});
40 }
41 throw rawError;
42 };
43}

Callers 5

createDeploymentAdapterFunction · 0.90
createProjectAdapterFunction · 0.90

Calls 1

mapContractErrorFunction · 0.85

Tested by

no test coverage detected