MCPcopy Create free account
hub / github.com/subquery/subql / mapContractError

Function mapContractError

packages/cli/src/controller/network/contract-errors.ts:8–16  ·  view source on GitHub ↗
(rawErrorMsg: any)

Source from the content-addressed store, hash-verified

6export type ContractErrorCode = keyof typeof contractErrorCodes;
7
8function mapContractError(rawErrorMsg: any): {revertCode?: ContractErrorCode; message?: string} {
9 const revertCode = Object.keys(contractErrorCodes).find(
10 (key) => rawErrorMsg.toString().match(`reverted: ${key}`) || (rawErrorMsg as any).reason === key
11 ) as ContractErrorCode;
12 return {
13 revertCode,
14 message: revertCode ? contractErrorCodes[revertCode] : undefined,
15 };
16}
17
18/**
19 * Parse a raw error from a contract call and throw a more descriptive error message if available.

Callers 1

parseContractErrorFunction · 0.85

Calls 1

findMethod · 0.65

Tested by

no test coverage detected