Choose Category
package main import ( "errors" "fmt" ) func main() { var car = Car{} car.name = "Audi" var _, error = car.getMileage() if errors.Is(error, myException) { fmt.Printf("in custom exception %+v", error) } else { println("in generic exception") } } type Car struct { name string } var myException = errors.New("unable to compute mileage") func (car Car) getMileage() (int, error) { return -1, myException }