When a caller makes a call to a callee, exception's are used to inform the caller that something different has happened so that he could change the flow of the program if required. In that sense, exception is not an error but a predictable outcome at layer of abstraction it was raised from. Most programming languages stop the execution if caller has no handlers to handle that situation.
The author of a library can detect errors, but does not in general have any idea what to do about them. The user of a library may know how to cope with such errors, but cannot detect them or else they would have been handled in the user’s code and not left for the library to find.
But what about things that can't be detected either because it was not reported or the detection mechanism was weak, probably in the hardware?
I have have seen at least two types of behaviors:
- The entire system just hangs. Hardware malfunction, faulty bios etc. are examples of such failures. Would it be fair to say that the error happened at a level where there was no recovery (like redundant hardware) mechanism, so the entire system failed?
- The system recovers for the next operation reporting that something unknown happened like "An unknown exception occurred! ". For example, a web-server that runs in a infinite
try-exceptloop is an example of such a scenario. In this case, the problem happened at a level where the recovery mechanism's job was to just report and continue?
I know this is a bit vague, but my main doubt is what happens when a completely unknown stuff happens! I am not talking about
PermissionDenied etc, but something nasty probably at hardware level that is yet to be discovered or documented etc?