|
|
|
|
|
by wvenable
1752 days ago
|
|
There's no need for even that complexity. If base exception type had a single property, something like "CanRetry", all exception handling would be simple. Because when it comes to exceptions there are really only 2 things you can do: abort the current operation or retry it. The code generating the exception will know which of these is appropriate and the try/catch handler is what would restart or cancel the operation. The exact details of the exception are for debugging not for program flow. |
|
"Can retry" _WHAT_? This can work if you meticulously rewrap low-level exceptions into higher-level ones that reflect the high-level operation that failed.
Concrete example: FileNotFoundException. I'd say that in "normal" circumstances it's not retriable: you're looking for a file, it's not there, so an exception is thrown. In "unusual" circumstances you're polling (i.e., waiting for a file to appear somehow) or you're an OS shell and is searching the path for the location of the program.