Exceptions
Exceptions are a mechanism provided by the runtime to make the execution suddenly interrupt and jump to the code handling the error. Since the handler may have been declared by any caller in the calling path, the runtime takes care of restoring the stack and any other outstanding finally
block, which we will examine in the The finally block section of this chapter.
The calling code may want to handle the exception and if it does, it may decide to resume normal execution or just let the exception continue to the other handlers (if any). Whenever no handling code is provided by the application, the runtime catches the error condition and does the only reasonable thing—it terminates the application.
This brings us back to the original question that we asked in the introduction—is the exception part of the contract between the library implementor and its consumer, or is it rather an implementation detail?
Since the implementor communicates an anomaly to...