Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > try-catch error handling -- display line number?

Reply
Thread Tools

try-catch error handling -- display line number?

 
 
Kim Haines
Guest
Posts: n/a
 
      09-07-2003
I need help finding where an error is occuring in my code. I use a
try-catch block like this in my global.asa:

try {

//my code

} catch (e) {
Application('errormsg') = ("An exception occurred in the script. Error
name: " + e.name
+ ". Error description: " + e.description
+ ". Error number: " + e.number
+ ". Error message: " + e.message); }

And this is what is SOMETIMES returned when I display
Application('errormsg'), the rest of the time, it works:

An exception occurred in the script. Error name: Error. Error description:
Path not found. Error number: -2146828212. Error message: Path not found

But I don't know which path is not found! (I'm using the filesystem object
and importing data from a file into SQL.) Is there a way to display the
line number of the error or more details? Or do I just have to try to catch
the error by going through each bit of code?


 
Reply With Quote
 
 
 
 
Janwillem Borleffs
Guest
Posts: n/a
 
      09-07-2003

"Kim Haines" <klhaines-remove-for-> schreef in bericht
news7K6b.47128$Qy4.4271@fed1read05...
>
> But I don't know which path is not found! (I'm using the filesystem

object
> and importing data from a file into SQL.) Is there a way to display the
> line number of the error or more details? Or do I just have to try to

catch
> the error by going through each bit of code?
>


A wild guess, but following MS's logics, try:

+ ". Error line: " + e.line


JW



 
Reply With Quote
 
 
 
 
Kim Haines
Guest
Posts: n/a
 
      09-07-2003
"Janwillem Borleffs" <> wrote in message
news:3f5bb704$0$28892$...
> A wild guess, but following MS's logics, try:
>
> + ". Error line: " + e.line


Oh, I tried that and e.lineNumber. Both return "undefined."

Then I read that try-catch doesn't provide a way to return the line number
if an error occurs.

I can't figure out which file access is causing the error, and it's
intermittent. I guess I'll start breaking down the code bit by bit.

Thanks.

--k


 
Reply With Quote
 
Janwillem Borleffs
Guest
Posts: n/a
 
      09-07-2003

"Janwillem Borleffs" <> schreef in bericht
news:3f5bb704$0$28892$...
>
> A wild guess, but following MS's logics, try:
>
> + ". Error line: " + e.line
>


No, doesn't work. When you run the following code in IE, you will see all
the properties and line isn't one of them:

try {
a_fish_in_the_pool;
} catch (e) {
for (var i in e) alert(i + ' = ' + e[i]);
}

A quick search with Google learned me that Mozilla stores the line number in
the lineNumber property and Opera appends it to the message property.

Perhaps you could use window.onerror instead, eg:

window.onerror = function (err, file, line) {
alert('The following error occured: ' + err + '\n' +
'In file: ' + file + '\n' +
'At line: ' + line);
return true;
}


HTH,
JW



 
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
Read a file line by line and write each line to a file based on the5th byte scad C++ 23 05-17-2009 06:11 PM
handling STDIN line by line in Gtk Michael Goerz Perl Misc 5 02-12-2007 11:06 PM
How to read a text file line by line and remove some line kaushikshome C++ 4 09-10-2006 10:12 PM
Read a file line by line with a maximum number of characters per line Hugo Java 10 10-18-2004 11:42 AM
bus error with printf line included, error without printf line? ben C Programming 4 06-26-2004 04:42 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57