There are cases where I don't know how to use exception handling. To make it clear, let me divide exceptions into two types:
1- exceptional cases that may happen occasionally, such as when you try to open a non-existent file. 2- exceptions that you wouldn't except to happen, if you have written your program correctly, such as out-of-range indexing.
exceptional cases that may happen occasionally, such as when you try to open a non-existent file.
exceptions that you wouldn't expect to happen if you have written your program correctly, such as out-of-range indexing.
In the first case i'dI'd prompt the user and/or return the program to a normal state, but I don't know what to do for the second type. If I don't catch them, the runtime will show its own message. If I wanted to handle it myself, I would have no idea of how to handle a case that was not supposed to happen whatsoever.