Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #32438

Re: What to do with an exception of Field.get()

From Tassilo Horn <tsdh@gnu.org>
Newsgroups comp.lang.java.programmer
Subject Re: What to do with an exception of Field.get()
Date 2015-08-28 16:57 +0200
Organization University Koblenz-Landau Campus Koblenz
Message-ID <874mjj8nqu.fsf@gnu.org> (permalink)
References <87fv33fsa6.fsf@Equus.decebal.nl> <87bndrfq7c.fsf@Equus.decebal.nl> <mrps1v$494$1@dont-email.me>

Show all headers | View raw


Eric Sosman <esosman@comcast-dot-net.invalid> 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

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

What to do with an exception of Field.get() Cecil Westerhof <Cecil@decebal.nl> - 2015-08-28 15:37 +0200
  Re: What to do with an exception of Field.get() Cecil Westerhof <Cecil@decebal.nl> - 2015-08-28 16:22 +0200
    Re: What to do with an exception of Field.get() Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-08-28 10:44 -0400
      Re: What to do with an exception of Field.get() Tassilo Horn <tsdh@gnu.org> - 2015-08-28 16:57 +0200
    Re: What to do with an exception of Field.get() Tassilo Horn <tsdh@gnu.org> - 2015-08-28 16:52 +0200

csiph-web