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


Groups > comp.lang.javascript > #21035

Re: Throw custom errors

From Stefan Weiss <krewecherl@gmail.com>
Newsgroups comp.lang.javascript
Subject Re: Throw custom errors
Date 2013-08-23 10:20 +0200
Organization albasani.net
Message-ID <kv760v$94a$1@news.albasani.net> (permalink)
References <2ccb206a-1a96-4852-a481-06490f106bce@googlegroups.com>

Show all headers | View raw


On 2013-08-23 08:59, CodeMeteor wrote:
> In the functions that I'm writing I throw an error when the given
> arguments are not of the correct datatype.
> When the error occurs, in the debug console of my web browser (chrome)
> the line number and file of the error that is shown is that where my
> throw statement is executed.
> Is it possible to make this line number and file show the line and
> file in which my function is called?

The developer console in Chrome gives you more than just the location of
the "throw" statement: you get a complete stack trace. Just expand the
error message by clicking the little arrow icon to the left.

Collapsed view:

  [x] > Uncaught Error: Something went wrong          included.js:2

Expanded view:

  [x] v Uncaught Error: Something went wrong          included.js:2
        badFunc                                       included.js:2
        (anonymous function)                          test.html:13

In this example, the function badFunc() in included.js throws the Error,
and it was called in test.html, line 13.

- stefan

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


Thread

Throw custom errors CodeMeteor <TimDGCB@gmail.com> - 2013-08-22 23:59 -0700
  Re: Throw custom errors Stefan Weiss <krewecherl@gmail.com> - 2013-08-23 10:20 +0200
  Re: Throw custom errors Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-08-23 16:35 +0200

csiph-web