Skip to content

Box<dyn Error> #20

@kolektiv

Description

@kolektiv

It's quite a common pattern (I think!) in throwaway scripts and example code at least (and I use it quite often just to play around with ideas) for a top-level main to return something like Result<(), Box<dyn Error>> - any normal errors can be converted to that, and it means you can have all kinds of different error-producing code called in your top-level main without having to worry about all of the errors converging to a concrete return type. However, that doesn't seem possible at the moment with exn - Exn<T> where T: Error doesn't have that conversion built in, and there's no simple way to fix that as a library user because of the orphan rule.

Would it be possible to address this in some way? I get that the general approach is to treat each module as an error boundary, but when you've got some experimental code calling all kinds of different parts of a codebase, having to .or_raise(...)? every function which was just ? in previous approaches is a bit of a pain for simple but rapidly changing code.

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