Go proposal: Type-safe error checking

76 points by cgrinds


benjajaja

Much better, but still bad.

I want to do an equivalent of rust's match:

switch t := err.(type) {
    case net.OpError: // t is now net.OpError
    ...
}

But I suppose that wouldn't deal with the whole unwrapping idea.

And then:

errors.AsType[*net.OpError](err)

How would I have guessed that it's a pointer? I would have tried a pointer, but because I know that most errors behind an error are pointers, but not all are. Notice the word "try", we are once again in "not sure until you run it" territory.

Some tiny progress here, but overall go has painted itself into a corner (with the type system, not just error handling).