errorx icon indicating copy to clipboard operation
errorx copied to clipboard

Decorate misbehave if err==nil

Open g7r opened this issue 4 years ago • 5 comments

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.

g7r avatar Jan 19 '22 10:01 g7r

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.

PeterIvanov avatar Jan 19 '22 10:01 PeterIvanov

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.

g7r avatar Jan 19 '22 11:01 g7r

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.

PeterIvanov avatar Jan 19 '22 11:01 PeterIvanov

@PeterIvanov is this issue resolved?

Tochemey avatar Sep 05 '23 22:09 Tochemey

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

PeterIvanov avatar Sep 06 '23 08:09 PeterIvanov