Error handling is important, but if it obscures logic, it’s wrong.
- Exceptions are better than returning error codes. When using exceptions we can just follow the logic path until the end, and if there is an exception it will be caught later.
^ So, he mentions this in a previous chapter, I have also included this here just so I can find it later
- When writing our tests, we should try to create tests that generate exceptions. This will force us to put all the correct logic inside the try block for our function.
- We should provide meaningful context to our exceptions
- We should not return null if something went wrong, if we return null, then we will have to check for null in every interaction
^ Ouch, can't count on my fingers the amount of times I wrote a function that returns null last month
- Passing null as an argument is even worst than returning it.