Some conflated ideas to tease apart here.
- Errors occur due to either external events or internally by not honoring a contract
- Contracts are more complex and harder to honor the more general a procedure is
- More general code has more error cases
- If you’re writing a function and it has a lot of error cases, check if you can eliminate some of them by removing unnecessary generality from the procedure
As always, simplest is best