3 ms·
Imagine you're writing a function that parses an integer from a string. Would you let it throw an exception on failure?
by amelius 5y ago
Imagine you're writing a function that parses an integer from a string. Would you let it throw an exception on failure?
- kaetemi 5y agoDepends 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.