Skip to content

Conversation

@Sypheos
Copy link
Member

@Sypheos Sypheos commented Oct 8, 2025

What does this PR do?

Add a new helper to As errors without having to instanciate a variable beforehand

Good PR checklist

  • Title makes sense
  • Is against the orrect branch
  • Only addresses one issue
  • Properly assigned
  • Added/updated tests
  • Added/updated documentation
  • Properly labeled

@Sypheos Sypheos self-assigned this Oct 8, 2025
@linear
Copy link

linear bot commented Oct 8, 2025

cause_go118.go Outdated
}
}

func AsOfType[T error](err error) (T, bool) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IsOfType reads okay but AsOfType is a bit dense & grammatically weird, how about AsType?

Suggested change
func AsOfType[T error](err error) (T, bool) {
func AsType[T error](err error) (T, bool) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, it won't have been the first time we mess with grammar in IT though 😄

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely 😅

}
}

func TestAsOfType(t *testing.T) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
func TestAsOfType(t *testing.T) {
func TestAsType(t *testing.T) {

@Sypheos Sypheos force-pushed the sylvainprost/vel-6221/error-as-of-type branch from 83cd99b to a4f2a9b Compare October 9, 2025 12:58
@Sypheos Sypheos merged commit e8e678a into master Oct 9, 2025
6 checks passed
@Sypheos Sypheos deleted the sylvainprost/vel-6221/error-as-of-type branch October 9, 2025 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants