Handling “Exceptions” that have a high probability of becoming “Errors”?

By convention, "Errors" indicate situations that the application just cannot handle or recover from it cleanly (ie, Disk Crash). Exception are abnormal situations that the application may try to recover from, or even clean up itself before shutting down I have find useful to split Exceptions in two more types: Business Exceptions, which are conditions caused by misconfiguration or mishandling of the application (ie, Validation exceptions), and Technical Exception which are conditions not caused by the application itself (ie, lost connection to the Database, Socket timeout, etc) Back to your question, pat of you is right: the model should be keep consistent at all times, and that should be enforced at the lowest level possible to promote reuse. Thus, put the validation in the model, try the operation and if it fails inform the user.

If you don't have Exceptions as a native mechanism in your language, I would go as far as returning a "result code" indicating the resulting status of the operation (ie, 0 - Success, 1 - Circular Dependency, 2 - Some unknown reason, etc).

By convention, "Errors" indicate situations that the application just cannot handle or recover from it cleanly (ie, Disk Crash). Exception are abnormal situations that the application may try to recover from, or even clean up itself before shutting down. I have find useful to split Exceptions in two more types: Business Exceptions, which are conditions caused by misconfiguration or mishandling of the application (ie, Validation exceptions), and Technical Exception which are conditions not caused by the application itself (ie, lost connection to the Database, Socket timeout, etc).

Back to your question, pat of you is right: the model should be keep consistent at all times, and that should be enforced at the lowest level possible to promote reuse. Thus, put the validation in the model, try the operation and if it fails inform the user. If you don't have Exceptions as a native mechanism in your language, I would go as far as returning a "result code" indicating the resulting status of the operation (ie, 0 - Success, 1 - Circular Dependency, 2 - Some unknown reason, etc).

I usually use the rule that if the user can correct the "error", then don't throw an exception. If the "error" is something truly unexpected and the user cannot fix his or her input to get past it, then it should throw an Exception. To go a level deeper, if you are actively checking for problems, such as writing code to make sure a file or folder path exists, then you should gracefully handle the situation and present it to the user without throwing an Exception.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions