Skip to content

proposal: Go 2: permit using errors.Return, etc., on LHS of an error assignment #37085

Closed
@ghost

Description

This approach has probably been discussed in the past. I like to make this a quick feedback.

Existing code:

bg, err := task.NewBackground()
If err != null {
…
}

If I could instantly identify different type of errors handling in a quick reading, it could be written with errors.### that are implements to receive strings, custom types, etc:

Radom ideas when return errors from .NewBackground() is not null:

bg, errors.Return := task.NewBackground()
bg, errors.Fatal := task.NewBackground()
bg, errors.Console := task.NewBackground()
bg, errors.Info := task.NewBackground()
bg, errors.Log := task.NewBackground()
bg, errors.CustomSentAlert := task.NewBackground()

Go runtime will handles according to each API.

Does this make sense for handling common errors? I could be wrong as to how these approach works or could be done on package.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions