Skip to content

Decorate misbehave if err==nil #40

Description

@g7r

What happens? errorx.Decorate returns an error with the following properties:

  • e.IsOfType(...) always returns false
  • e.Type() returns synthetic.foreign

I suggest that errorx.Decorate(nil, "") should either return nil or panic.

Activity

  1. PeterIvanov commented on Jan 19, 2022

    @PeterIvanov
    Collaborator

    Come to think of it, I agree. This is not an intended way to use the library.
    The issue is: this will potentially break some existing user code, which is a bad thing. At run time, which is worse.
    I'm not sure at this point that the reasoning along the lines of "but there's nothing in godoc that promised to keep this behaviour" is good enough.
    Need to think more about this.

  2. g7r commented on Jan 19, 2022

    @g7r
    ContributorAuthor

    Formally it looks more like not a breaking change but an API clarification. But I do agree that it might break some code.

    I would certainly object against solutions like "let's just introduce DecorateV2" 😄. Personally I think that it isn't a big deal in changing something that wasn't specified as a public contract.

  3. PeterIvanov commented on Jan 19, 2022

    @PeterIvanov
    Collaborator

    No, there may be only one Decorate.
    I think a breaking change would require a major release, and we may have other things of that sort to bundle together - say, a neglected issue of Wrap naming.

  4. Tochemey commented on Sep 5, 2023

    @Tochemey

    @PeterIvanov is this issue resolved?

  5. PeterIvanov commented on Sep 6, 2023

    @PeterIvanov
    Collaborator

    @Tochemey I'm afraid it is not. Do you have a comment on the subject matter, one way or another?

  6. added a commit that references this issue on Apr 14, 2026
    46c9395
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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