Skip to content

Proposal to propagated back to the caller an error returned by the invoked function #30

Closed
@dmvass

Description

@dmvass

What: propagated back to the caller an error returned by the invoked function doSomething

func doSomething() error {
    ...
    return errDo
}

...

if _, err := container.Invoke(doSomething); err != nil {
    if errors.Is(err , errDo) { 
        // handle doSomething error
    }
    // handle container errors
}

Invoked function result []any may be empty in this way.

Why:

  1. It's not very convenient to inspect and assert invoked function result []any just to check an error.
  2. The current documentation is not clear, and I expected a such behavior before looked to the source. So I guess that other developers may have the same opinion.
  3. It's similar to other dependency injection packages like Uber's dig.

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