By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,156 Members | 1,004 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,156 IT Pros & Developers. It's quick & easy.

try-catch error handling -- display line number?

P: n/a
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?
Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

"Kim Haines" <kl**********************@cox.net> schreef in bericht
news:x7K6b.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

Jul 20 '05 #2

P: n/a
"Janwillem Borleffs" <jw*@jwbfoto.demon.nl> wrote in message
news:3f***********************@news.euronet.nl...
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
Jul 20 '05 #3

P: n/a

"Janwillem Borleffs" <jw*@jwbfoto.demon.nl> schreef in bericht
news:3f***********************@news.euronet.nl...

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

Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.