Return-Path: Delivered-To: apmail-cocoon-users-archive@www.apache.org Received: (qmail 31603 invoked from network); 10 Jan 2007 03:17:18 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Jan 2007 03:17:18 -0000 Received: (qmail 80789 invoked by uid 500); 10 Jan 2007 03:17:17 -0000 Delivered-To: apmail-cocoon-users-archive@cocoon.apache.org Received: (qmail 80723 invoked by uid 500); 10 Jan 2007 03:17:17 -0000 Mailing-List: contact users-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: users@cocoon.apache.org List-Id: Delivered-To: mailing list users@cocoon.apache.org Received: (qmail 80712 invoked by uid 99); 10 Jan 2007 03:17:17 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Jan 2007 19:17:17 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (herse.apache.org: local policy) Received: from [74.52.162.130] (HELO mx11.mesanetworks.net) (74.52.162.130) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Jan 2007 19:17:07 -0800 Received: (qmail 424 invoked by uid 509); 9 Jan 2007 20:17:47 -0700 Received: from 65.175.0.109 by mx11.mesanetworks.net (envelope-from , uid 508) with qmail-scanner-1.25-st-qms (clamdscan: 0.87/2133. spamassassin: 3.0.6. perlscan: 1.25-st-qms. Clear:RC:1(65.175.0.109):. Processed in 0.093868 secs); 10 Jan 2007 03:17:47 -0000 X-Antivirus-MESANETWORKS-Mail-From: cocoon@lojjic.net via mx11.mesanetworks.net X-Antivirus-MESANETWORKS: 1.25-st-qms (Clear:RC:1(65.175.0.109):. Processed in 0.093868 secs Process 415) Received: from 65-175-0-109.static.mesanetworks.net (HELO ?192.168.0.100?) (65.175.0.109) by mx11.mesanetworks.net with SMTP; 9 Jan 2007 20:17:47 -0700 Message-ID: <45A45A91.3010004@lojjic.net> Date: Tue, 09 Jan 2007 20:16:33 -0700 From: Jason Johnston User-Agent: Thunderbird 1.5.0.9 (X11/20061206) MIME-Version: 1.0 To: users@cocoon.apache.org Subject: Re: how to catch and throw exceptions in cocoon2.1.10 (javascript) References: <000001c73408$af4780b0$6400a8c0@amert.nl> In-Reply-To: <000001c73408$af4780b0$6400a8c0@amert.nl> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Robby Pelssers, AGP wrote: > Hi, > > I'm facing a problem that my old javascript file no longer works > properly with constructions like instanceof, getClass(), throw. Can > someone point me out how to do this? > > try { > } catch (ex) { > if (ex instanceof Packages.xxxx.xxxx.xxxx) { > //Do something 1 > } else if (ex.getClass().getName().equals("xxxx")) { > //Do something 2 > } else { > //Do something 3 > throw(ex); > } > } If I recall, the new version of Rhino treats exceptions from the Java layer differently than it used to. It used to pass them up to the JS catch statement directly, whereas now it wraps them in a org.mozilla.javascript.WrappedException. You should be able to get access to your original Java exception by unwrapping it with ex.getWrappedException(). See http://www.mozilla.org/rhino/apidocs/org/mozilla/javascript/WrappedException.html --Jason --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org For additional commands, e-mail: users-help@cocoon.apache.org