Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #21034 > unrolled thread
| Started by | CodeMeteor <TimDGCB@gmail.com> |
|---|---|
| First post | 2013-08-22 23:59 -0700 |
| Last post | 2013-08-23 16:35 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.lang.javascript
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
| From | CodeMeteor <TimDGCB@gmail.com> |
|---|---|
| Date | 2013-08-22 23:59 -0700 |
| Subject | Throw custom errors |
| Message-ID | <2ccb206a-1a96-4852-a481-06490f106bce@googlegroups.com> |
Hi, 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?
[toc] | [next] | [standalone]
| From | Stefan Weiss <krewecherl@gmail.com> |
|---|---|
| Date | 2013-08-23 10:20 +0200 |
| Message-ID | <kv760v$94a$1@news.albasani.net> |
| In reply to | #21034 |
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
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2013-08-23 16:35 +0200 |
| Message-ID | <26013223.e07e5D6Rpa@PointedEars.de> |
| In reply to | #21034 |
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? No, but the line and the script resource is one of the next items in the stack trace. To this end, you might want to look into or use jsx.throwThis() which provides the information independent (but compatible to) the respective error console: <http://PointedEars.de/websvn/filedetails.php?repname=JSX&path=%2Ftrunk%2Fobject.js> Please get a real name, and use linebreaks. -- PointedEars Twitter: @PointedEars2 Please do not Cc: me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web