Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Getting a Traceback

Reply
Thread Tools

Getting a Traceback

 
 
Gene Wirchenko
Guest
Posts: n/a
 
      12-15-2011
Dear JavaScripters:

One of the realities that I will have to face is program crashes
when my app is finally in use. The current, non-Web version writes a
bunch of data to a file including a traceback. How do I get a
traceback in JavaScript?

I prefer a browser-independent answer, but if it has to be for
just one browser, then for IE 9.

Note that the usual of firing up the debugger will not do. This
is so I can get debugging information from end users.

Since I will use includes, the concept of line number could get
somewhat shaky. It would be nice to also get a copy of the page. By
this, I mean the code not the display. (Is there a term for this
entity?)

Sincerely,

Gene Wirchenko
 
Reply With Quote
 
 
 
 
Tim Streater
Guest
Posts: n/a
 
      12-15-2011
In article <(E-Mail Removed)>,
Gene Wirchenko <(E-Mail Removed)> wrote:

> Dear JavaScripters:
>
> One of the realities that I will have to face is program crashes
> when my app is finally in use. The current, non-Web version writes a
> bunch of data to a file including a traceback. How do I get a
> traceback in JavaScript?
>
> I prefer a browser-independent answer, but if it has to be for
> just one browser, then for IE 9.
>
> Note that the usual of firing up the debugger will not do. This
> is so I can get debugging information from end users.
>
> Since I will use includes, the concept of line number could get
> somewhat shaky. It would be nice to also get a copy of the page. By
> this, I mean the code not the display. (Is there a term for this
> entity?)


How far do you want the traceback to go? I'm not sure one can get a call
stack. As it is, I use the window.onerror method to record where an
error occurs (such as null pointer), thus:

window.onerror = function (msg, url, linenum)
{
var data = "msg=" + msg + "&url=" + url + "&linenum=" + linenum;
ajax ("myJSerror.php", data, logMessage);
return true; // Error still reported in error console
}

I had to poke around a bit to find the parameter sequence for this
method, but the above seems to be correct (in Safari at any rate). So if
there *is* a null pointer, I can construct a message that I send to a
PHP script that records it in my log file.

I believe window.onerror is pretty widely supported. I use includes too
but the line number reported still agrees with what I see in my text
editor (I tested this in Safari).

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"raise (type, value, traceback)" and "raise type, value, traceback" Jack Bates Python 0 05-02-2011 05:23 PM
Re: getting error...... Traceback (most recent call last): File"<stdin>", line 1, in <module> File Gabriel Genellina Python 4 12-10-2008 11:06 AM
Getting better traceback info on exec and execfile - introspection? R. Bernstein Python 8 01-16-2006 09:15 AM
getting tracebacks from traceback objects Michael P. Soulier Python 1 06-24-2005 10:56 AM
sys.excepthook, getting traceback values Josh Close Python 1 07-23-2004 03:23 PM



Advertisments