DEV Community

Discussion on: Go 2 Draft: Error Handling

Collapse
 
m_kunc profile image
Martin Kunc • Edited

Hi Dean,
I feel like adding handle fallbacks is limiting my chance to spot which place exactly generated the error.
Originally we could generate different errors for various reason. The example above is actually using same messages all the time. I know we have the line number, but I still preferred the "copyfile os.open error %s" format to specify exact spot individually.
I am not saying this won't allow it, it will just look very similar.

I would love it we would have also name of function passed to handler, ie:

handle err, fn {
  log.Fatal(fmt.Errorf("%s %s", fn, err))
}

hex := check ioutil.ReadAll(os.Stdin)
data := check parseHexdump(string(hex))

What do you think ?

Collapse
 
dean profile image
dean

I actually quite like this idea! I'd suggest heading over to the wiki and put it there!