Skip to content

Support custom errors #61

@AuHau

Description

@AuHau

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions