MCPcopy Create free account
hub / github.com/wevm/viem / getNodeError

Function getNodeError

src/utils/errors/getNodeError.ts:62–119  ·  view source on GitHub ↗
(
  err: BaseError,
  args: GetNodeErrorParameters,
)

Source from the content-addressed store, hash-verified

60 | UnknownNodeErrorType
61
62export function getNodeError(
63 err: BaseError,
64 args: GetNodeErrorParameters,
65): GetNodeErrorReturnType {
66 const message = (err.details || '').toLowerCase()
67
68 const executionRevertedError =
69 err instanceof BaseError
70 ? err.walk(
71 (e) =>
72 (e as { code: number } | null | undefined)?.code ===
73 ExecutionRevertedError.code,
74 )
75 : err
76 if (executionRevertedError instanceof BaseError)
77 return new ExecutionRevertedError({
78 cause: err,
79 message: executionRevertedError.details,
80 }) as any
81 if (ExecutionRevertedError.nodeMessage.test(message))
82 return new ExecutionRevertedError({
83 cause: err,
84 message: err.details,
85 }) as any
86 if (FeeCapTooHighError.nodeMessage.test(message))
87 return new FeeCapTooHighError({
88 cause: err,
89 maxFeePerGas: args?.maxFeePerGas,
90 }) as any
91 if (FeeCapTooLowError.nodeMessage.test(message))
92 return new FeeCapTooLowError({
93 cause: err,
94 maxFeePerGas: args?.maxFeePerGas,
95 }) as any
96 if (NonceTooHighError.nodeMessage.test(message))
97 return new NonceTooHighError({ cause: err, nonce: args?.nonce }) as any
98 if (NonceTooLowError.nodeMessage.test(message))
99 return new NonceTooLowError({ cause: err, nonce: args?.nonce }) as any
100 if (NonceMaxValueError.nodeMessage.test(message))
101 return new NonceMaxValueError({ cause: err, nonce: args?.nonce }) as any
102 if (InsufficientFundsError.nodeMessage.test(message))
103 return new InsufficientFundsError({ cause: err }) as any
104 if (IntrinsicGasTooHighError.nodeMessage.test(message))
105 return new IntrinsicGasTooHighError({ cause: err, gas: args?.gas }) as any
106 if (IntrinsicGasTooLowError.nodeMessage.test(message))
107 return new IntrinsicGasTooLowError({ cause: err, gas: args?.gas }) as any
108 if (TransactionTypeNotSupportedError.nodeMessage.test(message))
109 return new TransactionTypeNotSupportedError({ cause: err }) as any
110 if (TipAboveFeeCapError.nodeMessage.test(message))
111 return new TipAboveFeeCapError({
112 cause: err,
113 maxFeePerGas: args?.maxFeePerGas,
114 maxPriorityFeePerGas: args?.maxPriorityFeePerGas,
115 }) as any
116 return new UnknownNodeError({
117 cause: err,
118 }) as any
119}

Callers 6

simulateBlocksFunction · 0.85
getTransactionErrorFunction · 0.85
getCallErrorFunction · 0.85
getEstimateGasErrorFunction · 0.85
simulateBlocksFunction · 0.85

Calls 1

walkMethod · 0.80

Tested by

no test coverage detected