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


Groups > comp.lang.javascript > #30616

Re: try ... catch for a specific error ?

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 16:03:10 +0200
Organization solani.org
Lines 22
Message-ID <nipeap$4db$1@solani.org> (permalink)
References <574fe5c6$0$5901$e4fe514c@news.xs4all.nl> <nip2aa$lvc$1@solani.org> <5750271d$0$5837$e4fe514c@news.xs4all.nl> <nip9et$h5d$1@solani.org> <575036d4$0$5889$e4fe514c@news.xs4all.nl>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 7bit
X-Trace solani.org 1464876185 4523 eJwNysEBwCAIA8CVqBLAcTSY/Ueo7zvM+ILpgXAIUiYP9pifl3BLu9iFm3Tf0b3Y4LEb+aZyDHGAkldUmFpPvZzncq0DWZZPQ99m0nL94R4frA== (2 Jun 2016 14:03:05 GMT)
X-Complaints-To abuse@news.solani.org
NNTP-Posting-Date Thu, 2 Jun 2016 14:03:05 +0000 (UTC)
User-Agent Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1
X-User-ID eJwNwokRwCAMA7CVyB/GMQ7sP0J7UlhKsjwjPd5PqTvWNd9gLW1yaqxl5hIwOQ+N8RY1HK0PHusRfg==
In-Reply-To <575036d4$0$5889$e4fe514c@news.xs4all.nl>
Cancel-Lock sha1:+nONBvA5A/YqdFKYQYIie76hh/U=
X-NNTP-Posting-Host eJwFwQkBwDAIA0BL5W0jhwHxL2F3YSnZ1zPSg0Fuh5OgpsKMkjZvSa26iJ06Vu8zR/IV5tYqr7h0L7psm3vG0Jp3vpjwlyI4dnwZUPzb0x8I
Xref csiph.com comp.lang.javascript:30616

Show key headers only | View raw


On 02.06.2016 at 15:40, R.Wieser wrote:

>> Most likely for a good reason: this error constant appears to be
>> highly user-agent specific.
> 
> Its not about that specific constant (regard it as an example), but about
> how I compare *any* error-constant to the returned error/exception object.
> Can I check if a specific error has been thrown, and if so how ?

You can apply the usual comparison operators, typeof, instanceof etc.
Note that JavaScript allows objects and scalar values to be thrown.

For your concrete case see JJ's response
(<news:yua8gzzjdwv9$.z2ar9grudtz1$.dlg@40tude.net>).

> As for that constant being rather user-agent specific ?   JavaScript isn't
> only used in webpages. :-)

Indeed, I should have written "host environment specific".

-- 
Christoph M. Becker

Back to comp.lang.javascript | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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