Some conflated ideas to tease apart here.

  1. Errors occur due to either external events or internally by not honoring a contract
  2. Contracts are more complex and harder to honor the more general a procedure is
  3. More general code has more error cases
  4. 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