Conversation
cause_go118.go
Outdated
| } | ||
| } | ||
|
|
||
| func AsOfType[T error](err error) (T, bool) { |
There was a problem hiding this comment.
IsOfType reads okay but AsOfType is a bit dense & grammatically weird, how about AsType?
| func AsOfType[T error](err error) (T, bool) { | |
| func AsType[T error](err error) (T, bool) { |
There was a problem hiding this comment.
I'm torn, this is nice, but we already have a IsOfType and not IsType. In that case, I prefer to let consistency win here
There was a problem hiding this comment.
Consistency kinda fucks over grammar here, which is why I prefer AsType. IsOfType is valid cos it means the error is of a given type, IsType would be wrong because it's an error, not a type.
AsOfType just doesn't mean anything in English, so consistency will really hurt readability here imo
There was a problem hiding this comment.
Alright, it won't have been the first time we mess with grammar in IT though 😄
682336a to
83cd99b
Compare
cause_go118_test.go
Outdated
| } | ||
| } | ||
|
|
||
| func TestAsOfType(t *testing.T) { |
There was a problem hiding this comment.
nit:
| func TestAsOfType(t *testing.T) { | |
| func TestAsType(t *testing.T) { |
83cd99b to
a4f2a9b
Compare
What does this PR do?
Add a new helper to
Aserrors without having to instanciate a variable beforehandGood PR checklist