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


Groups > comp.lang.java.help > #1592

Re: Catching Thrown Exceptions

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail
From Lew <noone@lewscanon.com>
Newsgroups comp.lang.java.help
Subject Re: Catching Thrown Exceptions
Date Tue, 21 Feb 2012 16:14:28 -0800
Organization albasani.net
Lines 47
Message-ID <ji1c14$7fe$1@news.albasani.net> (permalink)
References <6693b355-c89b-4855-b6d3-0ed7e532cc88@c21g2000yqi.googlegroups.com> <a29b4926-7e8e-4753-94f8-7f8da93bcd7a@a15g2000yqf.googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace news.albasani.net AKVaR+Kuqd+Wp390ouxOMzrxPr9aAX/zoo8eihF7xNebua7dsK3ybK52WGKhb7P93VcSN+xvX2nuV0yh1RTMuL1MmfjLT1RGke3niZfRTzCkMsdiKshRloMENq6WCtqH
NNTP-Posting-Date Wed, 22 Feb 2012 00:14:28 +0000 (UTC)
Injection-Info news.albasani.net; logging-data="nQ3UY94c9qBYnKan7K7SvIPc7HzQgRKX4FJRiXB892wl02W4pBUThYNIHEyv2KJHoOFuzfbkyyq/Tt2yNKDXsWJWC2Vph799V9Wo3I09jidZ7UYdGHScRvYyzZNH6+WZ"; mail-complaints-to="abuse@albasani.net"
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
In-Reply-To <a29b4926-7e8e-4753-94f8-7f8da93bcd7a@a15g2000yqf.googlegroups.com>
Cancel-Lock sha1:qYV8Iy/KtihNrouSxD/F2a+BAzQ=
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.help:1592

Show key headers only | View raw


"Davej" wrote:
> "Davej" wrote:
>> I figured that if you threw an exception inside a try it would be
>> caught. No? In my Java program the throw was not caught. In C# this is
>> the way things work.
>
> Ok, I apologize for not including specific details. This is a jsp file
> and I had the following inside a try block...
>
> if ( condition )
> {
>     throw exception;
> }

You shouldn't have Java source in a JSP page.

> This compiled but didn't work. Now I seem to have it working with...

Perhaps you are aware that 'exception' is a predefined variable in an error 
JSP that has value only when there actually is an exception? Or perhaps you 
mean something different by "compiled" than I do? You send us these code 
fragments that yield no context. On the face of it I don't know how your code 
fragment was able to compile successfully.

> if ( condition )
> {
>     throw new Exception();
> }

I trust that you are not, indeed, doing that from a JSP page. That would be 
ghastly.

Also, don't throw 'Exception', throw a suitable subtype.

Also, I trust that you are both including relevant information in the message 
of the exception, and logging it.

Who knows? We can't unless you tell us. But based on what you post, it sounds 
like your code needs an awful lot of work.

Consider
http://sscce.org/

-- 
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg

Back to comp.lang.java.help | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Catching Thrown Exceptions Davej <galt_57@hotmail.com> - 2012-02-20 22:36 -0800
  Re: Catching Thrown Exceptions Lew <noone@lewscanon.com> - 2012-02-20 23:33 -0800
  Re: Catching Thrown Exceptions Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-02-21 07:58 -0500
  Re: Catching Thrown Exceptions Roedy Green <see_website@mindprod.com.invalid> - 2012-02-21 10:12 -0800
  Re: Catching Thrown Exceptions Davej <galt_57@hotmail.com> - 2012-02-21 11:56 -0800
    Re: Catching Thrown Exceptions Lew <noone@lewscanon.com> - 2012-02-21 16:14 -0800
      Re: Catching Thrown Exceptions Davej <galt_57@hotmail.com> - 2012-02-23 09:20 -0800
        Re: Catching Thrown Exceptions markspace <-@.> - 2012-02-23 10:13 -0800
        Re: Catching Thrown Exceptions Lew <noone@lewscanon.com> - 2012-02-23 14:34 -0800
        Re: Catching Thrown Exceptions Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-02-23 14:47 -0800
        Re: Catching Thrown Exceptions Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-02-23 20:45 -0400
    Re: Catching Thrown Exceptions Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2012-02-22 14:02 +0200
      Re: Catching Thrown Exceptions Lew <noone@lewscanon.com> - 2012-02-22 08:00 -0800
  Re: Catching Thrown Exceptions Davej <galt_57@hotmail.com> - 2012-02-21 12:35 -0800
    Re: Catching Thrown Exceptions Lew <noone@lewscanon.com> - 2012-02-21 16:17 -0800

csiph-web