Fail Fast
There’s two attitude to handle error. Fail safe or fail fast. Failing safe means trying to handle the error perfectly. For example, providing an fallback value and trying to keep the system from crashing. Failing fast, on the other hand, tries to crash and stop the system as soon as an error happens.
I learned that we should prefer fail fast (when handling unexpected errors) for the following reasons:
- It shows the “source” of the error. (If we try to provide some fake fallbacks, it will stay in the system and will be hard to trace the source of the error.)
- The more errors you detect, the more bugs you fix.
I believe that the rule applies more on a developing product. However, it should be a good idea to keep in mind.