custom struct error?
type MyErr struct {
fields....
}
func (e *MyErr) Error() string {
return fmt.Sprintf("failed with %s", field1,...)
}
question unclear
how do I check an error is of type` MyErr`? I can't use errors.Is(err, MyErr)
it expects an instance, not a type. So I wonder if doing just errors.Is(err, &MyErr{}) is the correct way
that's what I'm currently using, I thought Is/As is the preferred way
Not necessarily, it depends
Обсуждают сегодня