Path: csiph.com!weretis.net!feeder4.news.weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: "Christoph M. Becker" 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: References: <574fe5c6$0$5901$e4fe514c@news.xs4all.nl> <5750271d$0$5837$e4fe514c@news.xs4all.nl> <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 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 (). > 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