Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Imagine you're writing a function that parses an integer from a string. Would you let it throw an exception on failure?


Depends on whether you call the function `parse` or `tryParse`. :)

Throw if you expect that the input should never be invalid.

Don't throw, and do friendly logging and reporting of your parsing errors, if this is uncontrollable third party input.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: