Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom errors #61

Open
AuHau opened this issue Oct 25, 2024 · 0 comments
Open

Support custom errors #61

AuHau opened this issue Oct 25, 2024 · 0 comments

Comments

@AuHau
Copy link
Member

AuHau commented Oct 25, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant