Thanks to Chronos v4 supports proper raises tracking, it now makes more sense to use exception tracking and specifically also custom errors to correctly signal error types.
I have a custom error type, that I have correctly added to raises and created for it specific Result type like this:
type
SubscriptionError* = object of EthersError
SubscriptionResult*[E] = Result[E, ref SubscriptionError]
When I used it with Questionable like this:
proc onBlock(blckResult: SubscriptionResult[Block]) =
without blck =? blckResult, err:
raise err
Then I got an error from Nim that points out that the raised error is ref CatchableError type and not ref SubscriptionError. If I use the Result's API directly, then the expected error is correctly ref SubscriptionError
Thanks to Chronos v4 supports proper
raisestracking, it now makes more sense to use exception tracking and specifically also custom errors to correctly signal error types.I have a custom error type, that I have correctly added to
raisesand created for it specificResulttype like this:When I used it with Questionable like this:
Then I got an error from Nim that points out that the raised error is
ref CatchableErrortype and notref SubscriptionError. If I use the Result's API directly, then the expected error is correctlyref SubscriptionError