nim-ethers/ethers/errors/conversion.nim
Mark Spanbroek 131316de08 move error conversion from TransactionResponse to Confirmable
Ensures that provider no longer needs to know about error
conversion, it now localized in contract.nim.

Co-Authored-By: Eric Mastro <eric.mastro@gmail.com>
2024-05-21 13:19:24 +02:00

16 lines
456 B
Nim

import ../basics
import ../provider
import ./encoding
type ConvertCustomErrors* =
proc(error: ref ProviderError): ref EthersError {.gcsafe, raises:[].}
func customErrorConversion*(ErrorTypes: type tuple): ConvertCustomErrors =
func convert(error: ref ProviderError): ref EthersError =
if data =? error.data:
for e in ErrorTypes.default.fields:
if error =? typeof(e).decode(data):
return error
return error
convert