Let’s dive in.
Something that’s definitely an error is a bug. Some examples of bugs are:
- runtime exceptions
- calling a function with invalid arguments
- invalid state in your program. For example, something being
nullwhen it’s not supposed to be.
There are more things that are normally considered "errors". Some examples are:
- failing to send a network request, because the user lost internet connection
- failing to find a file, because the user deleted it a few milliseconds ago
These are things that your program can’t do anything about. They will fail sometimes. For example, your program might confirm that a user is connected to the internet. But, when it sends a network request, it may fail to send. Maybe the internet connection dropped halfway through the network request.
Most other things are not errors. They are considered "normal". For example, something in your program might be
null. If it’s supposed to be
null, it’s not an error. As another example, a user may provide invalid input. Again, that’s not an error. It’s normal and expected.
Error letters image – Photo by Ann H from Pexels