This question is related to both of these questions - Efficient try / catch block usage? and Dealing with error in data - Idempotent approach.

When I encounter a void while reading a GIS data file I throw an Exception. This Exception is a subclass of java.lang.Exception. The question is of what happens after the void data exception is reached. Post processing would require that I go to another URL where the void filled data file is available and then download that and then proceed to read it in.

From the "efficient-try-catch-block-usage" question it appears doing inside this the catch block is a strict NO. Would it better then instead of throwing an application specific exception it is better to check for a return code or a post condition and proceed to do the post processing ?

有帮助吗?

解决方案

It depends on how much of a performance hit you can reasonably accept when throwing the exception. If it only happens once, it might not be a big deal. If it happens every line of the file, it could be a huge problem.

Normally exceptions are thrown when something happens that you can't do anything about, and execution is stopped.

许可以下: CC-BY-SA归因
scroll top