Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #30608
| Path | csiph.com!weretis.net!feeder4.news.weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail |
|---|---|
| From | "Christoph M. Becker" <cmbecker69@arcor.de> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: try ... catch for a specific error ? |
| Date | Thu, 2 Jun 2016 12:38:07 +0200 |
| Organization | solani.org |
| Lines | 24 |
| Message-ID | <nip2aa$lvc$1@solani.org> (permalink) |
| References | <574fe5c6$0$5901$e4fe514c@news.xs4all.nl> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 7bit |
| X-Trace | solani.org 1464863882 22508 eJwFwYEBwCAIA7CX7IA6zkEp/59gEkbwbmfQY2J4Bn/3lFSLVH/qZMIufNtUS+tkX5ukCnhBixJV (2 Jun 2016 10:38:02 GMT) |
| X-Complaints-To | abuse@news.solani.org |
| NNTP-Posting-Date | Thu, 2 Jun 2016 10:38:02 +0000 (UTC) |
| User-Agent | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 |
| X-User-ID | eJwNxMEBgDAIA8CZIiHAOApl/xHqPc5NUAfloq/vH/fIaJX0+RSFtIBejtGFRucO6sRzOucCBNkQjg== |
| In-Reply-To | <574fe5c6$0$5901$e4fe514c@news.xs4all.nl> |
| Cancel-Lock | sha1:0lfLzTiRectHHZ494bQMweQ5cAA= |
| X-NNTP-Posting-Host | eJwVwokRACEIBLCWYPnOclCX/ktwbpKw1DzlGekxPzbhxa6NtiXXbe0IUFV2QIes84nwjqDwACUkER8= |
| Xref | csiph.com comp.lang.javascript:30608 |
Show key headers only | View raw
On 02.06.2016 at 09:54, R.Wieser wrote:
> I'm executing a command which can return a specific error constant
> indicating the item is not found. I would like to catch that error alone
> (returning an empty string instead of failing), and have the system handle
> all others.
>
> Two seperate questions:
> 1) Can I tell the "catch" to only do so on (a) specific error(s) ?
You can do something like:
try {
// ...
} catch (ex) {
if (weAreInterestedInHandlingTheException(ex)) {
// handle the exception
} else {
throw ex;
}
}
--
Christoph M. Becker
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
try ... catch for a specific error ? "R.Wieser" <address@not.available> - 2016-06-02 09:54 +0200
Re: try ... catch for a specific error ? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-06-02 11:21 +0200
Re: try ... catch for a specific error ? "R.Wieser" <address@not.available> - 2016-06-02 12:18 +0200
Re: try ... catch for a specific error ? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-06-02 13:22 +0200
Re: try ... catch for a specific error ? "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-06-02 12:38 +0200
Re: try ... catch for a specific error ? "R.Wieser" <address@not.available> - 2016-06-02 14:32 +0200
Re: try ... catch for a specific error ? "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-06-02 14:40 +0200
Re: try ... catch for a specific error ? "R.Wieser" <address@not.available> - 2016-06-02 15:40 +0200
Re: try ... catch for a specific error ? "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-06-02 16:03 +0200
Re: try ... catch for a specific error ? "R.Wieser" <address@not.available> - 2016-06-02 16:23 +0200
Re: try ... catch for a specific error ? "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-06-02 16:43 +0200
Re: try ... catch for a specific error ? Tim Streater <timstreater@greenbee.net> - 2016-06-02 20:42 +0100
Re: try ... catch for a specific error ? Tim Streater <timstreater@greenbee.net> - 2016-06-02 20:44 +0100
Re: try ... catch for a specific error ? JJ <jj4public@vfemail.net> - 2016-06-02 20:24 +0700
Re: try ... catch for a specific error ? "R.Wieser" <address@not.available> - 2016-06-02 16:35 +0200
Re: try ... catch for a specific error ? "R.Wieser" <address@not.available> - 2016-06-03 10:50 +0200
Re: try ... catch for a specific error ? "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-06-03 17:35 +0200
Re: try ... catch for a specific error ? "R.Wieser" <address@not.available> - 2016-06-03 22:25 +0200
Re: try ... catch for a specific error ? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-06-03 23:55 +0200
csiph-web