Path: csiph.com!news.swapon.de!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!news-1.dfn.de!news.dfn.de!cache.uni-koblenz.de!not-for-mail From: Tassilo Horn Newsgroups: comp.lang.java.programmer Subject: Re: What to do with an exception of Field.get() Date: Fri, 28 Aug 2015 16:57:13 +0200 Organization: University Koblenz-Landau Campus Koblenz Lines: 22 Message-ID: <874mjj8nqu.fsf@gnu.org> References: <87fv33fsa6.fsf@Equus.decebal.nl> <87bndrfq7c.fsf@Equus.decebal.nl> NNTP-Posting-Host: 2.160.110.50 Mime-Version: 1.0 Content-Type: text/plain X-Trace: cache.uni-koblenz.de 1440773833 24656 2.160.110.50 (28 Aug 2015 14:57:13 GMT) X-Complaints-To: news@cache.uni-koblenz.de NNTP-Posting-Date: Fri, 28 Aug 2015 14:57:13 +0000 (UTC) User-Agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.0.50 (gnu/linux) Cancel-Lock: sha1:bfyPqiPeyb1Tqgw3VgmCvj2eD20= Xref: csiph.com comp.lang.java.programmer:32438 Eric Sosman writes: >> In principle you never know where your function is used. (If you share >> it.) So I wrote a custom exception (which gives a stacktrace). In this >> way the user only has to check for one exception (it is used in Java >> 6) and can decide what to do. > > That seems the right approach. If you haven't done so already, > it's a good idea to propagate the original exception as the "cause" > of the one eventually thrown: > > try { > ... > } catch (IllegalArgumentException | IllegalAccessException ex) { > throw new WrapperException("Yikes!", ex); > } Catching exceptions of multiple types with one catch clause is only supported as of Java 7, I think. Bye, Tassilo