What a great way to handle the exception that is thrown in the end
block ?
For example:
try {// use resource} hold (exception pre) {// problem with resource. } {Try {source.close ()}} Finally (Exceptional) {// Resource could not be closed? }}
How can you avoid try
/ catch
from end
?
I usually do this like this:
try { // Use the resource. } Hold (Exception Pre) {// Problem with Resource. } Finally {// keep the resource off-quilting (resource); }
elsewhere:
secure zero-free questions (resource processing) {try (if (resource! = Zero) {resource.close (); }} Hold (exception before) {log ("Exceptions during resource.closures"), prior);}}
Comments
Post a Comment