2024-03-21 08:32:15 +00:00
|
|
|
import ../basics
|
|
|
|
import ../provider
|
|
|
|
import ./encoding
|
|
|
|
|
2024-05-14 15:43:53 +00:00
|
|
|
type ConvertCustomErrors* =
|
|
|
|
proc(error: ref ProviderError): ref EthersError {.gcsafe, raises:[].}
|
|
|
|
|
2024-03-21 08:32:15 +00:00
|
|
|
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
|