tendermint / coding

14 stars 10 forks source link

all: discourage panics in libraries/packages where possible #23

Closed odeke-em closed 6 years ago

odeke-em commented 7 years ago

I would like to propose that we discourage panics within library/packages unless something is totally unrecoverable or if it is a sanity check. I've seen a bunch of panics in our libraries for functions with signatures that could be modified to return an error. IMHO packages should be the glue code that userland code invokes and shouldn't get surprised by; userland code includes CLIs, servers, handlers etc. What do y'all think?

zramsay commented 7 years ago

totally. panics is like lazy error checking while writing code quickly. our codes panic far too much

jaekwon commented 6 years ago

You'll have to point at where the panics are, each should be discussed on a case-by-case basis.

It's good to panic when a library is used the wrong way (e.g. developer error). That's how it is in the standard-library. Agreed that in general there should be less panic'ing in libraries. But it's not to be avoided.