How to get the real error stack trace from an error in an Angular app?

2,345 views
Skip to first unread message

Vlad GURDIGA

unread,
Dec 10, 2013, 12:47:08 AM12/10/13
to ang...@googlegroups.com

Hi guys!

I’m wondering if there is any way to get the real trace from an error thrown, say, from one of my Angular services. Right now, if I have throw 'Some error message', I get something like this in the browser console:

See? That is thrown from js/app/procedura/services/procedura.js:12 but there is no reference to that fie and that line number in the stack trace. :-/

Sander Elias

unread,
Dec 10, 2013, 2:10:06 AM12/10/13
to ang...@googlegroups.com
Hi Vlad,

have a look at this: http://goo.gl/bvXBk9
Is that what you would like to see?

Regards
Sander

Vlad GURDIGA

unread,
Dec 10, 2013, 3:32:18 AM12/10/13
to ang...@googlegroups.com
Thanks a lot Sander, this is a lot better. :)
Inline image 1
But, still I wonder why Angular decided to go that way…



--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/VENpGKwCeyM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.

image.png

Sander Elias

unread,
Dec 10, 2013, 3:51:33 AM12/10/13
to ang...@googlegroups.com
They didn't it's a standard error. You wheren't adding your part;)

Vlad GURDIGA

unread,
Dec 10, 2013, 3:56:09 AM12/10/13
to ang...@googlegroups.com
Um… I may be missing something, but why should I add anything to see my standard JS error stack traces?! :)

Sander Elias

unread,
Dec 10, 2013, 7:45:30 AM12/10/13
to ang...@googlegroups.com
Hi Vlad,

Well, if you trow an error, you are responsible for it! 
trow "I'm an error"
does not add anything to the call stack! After that, Angular picks up, and adds the angular call stack. but angular doesn't know about yours!

if you want a call stack, you have to do something like:
throw new Error("I'm an error")
that will add an call-stack! As it is doing in my example!

Regards
Sander Elias

Vlad GURDIGA

unread,
Dec 10, 2013, 9:06:28 AM12/10/13
to ang...@googlegroups.com
Ouch! …I see what you mean… my bad. :>
Reply all
Reply to author
Forward
0 new messages