Den måndag 24 april 2017 kl. 11:02:55 UTC+2 skrev Sokolov Yura: > > I want to ask: > - how useful `recover` for you? >
In one piece of code it was extremely handy. A TLV protocol decoder taking a bytes buffer as input. The TLVs could be nested so TLVs containing TLVs etc. Instead of manually bounds checking each TLV i just relied on the out of bounds checking provided by Go. In the top level decode function I recovered the out of bounds panic raised by the run time and converted it to an error that was returned the usual way. So yea, basically excpetions :-) > - Don't you think it is a bit "dangerous"? > > No, but in my own "library code" I have never called panic without internally caught it with recover and converter it to an error. I don't count bounds checking panics etc as I count those as bugs (with the exception of the example above). -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.