473,544 Members | 1,800 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

try-catch error handling -- display line number?

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('er rormsg') = ("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('er rormsg'), 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
3 51978

"Kim Haines" <kl************ **********@cox. net> schreef in bericht
news:x7K6b.4712 8$Qy4.4271@fed1 read05...

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
"Janwillem Borleffs" <jw*@jwbfoto.de mon.nl> wrote in message
news:3f******** *************** @news.euronet.n l...
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

"Janwillem Borleffs" <jw*@jwbfoto.de mon.nl> schreef in bericht
news:3f******** *************** @news.euronet.n l...

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_p ool;
} 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

39
6016
by: Erlend Fuglum | last post by:
Hi everyone, I'm having some trouble sorting lists. I suspect this might have something to do with locale settings and/or character encoding/unicode. Consider the following example, text containing norwegian special characters æ, ø and å. >>> liste =
12
2465
by: Brian Kelley | last post by:
def res(): try: a = 1 return finally: print "do I get here?" res() outputs "do I get here?"
9
3804
by: David Stockwell | last post by:
In referring to my copy of the python bible, it tells me I can't use all three items 'try' except and finally. I can use the t/f or t/e combinations though What combination can i use if i want to catch the exception and still have a finally block? This is a fictional example of what I want....
6
3374
by: William Park | last post by:
(crossposted to comp.lang.python, because this may be of interest to them.) Python has try-block, within which you can raise exception. Once it's raised, execution breaks out of the try-block and is caught at the end of try-block. Now, Bash has similiar feature. I've added try-block and 'raise' builtin into Bash-3.0. Typical usage...
3
2178
by: Steven Bethard | last post by:
So I have code that looks something like this: def f(xs): for x in xs: y = g(x) # can raise exception AnException for z in h(y): k(z) # can raise a variety of exceptions Now, if g(x) raises AnException, I want to log something and skip the inner loop (but continue with the outer loop). If k(z) raises an
40
2989
by: Steve Juranich | last post by:
I know that this topic has the potential for blowing up in my face, but I can't help asking. I've been using Python since 1.5.1, so I'm not what you'd call a "n00b". I dutifully evangelize on the goodness of Python whenever I talk with fellow developers, but I always hit a snag when it comes to discussing the finer points of the execution...
4
2432
by: wk6pack | last post by:
Hi, I was wondering why when I declare the dim variable outside the try statement, I could use the .dispose() function but when I declare it inside the try statement, I get Name 'varname' is not declared. thanks, Will
3
2230
by: Sori Schwimmer | last post by:
Hi, I think that would be useful to have an improved version of the "try" statement, as follows: try(retrys=0,timeout=0): # things to try except: # what to do if failed
3
2014
by: Bob Rock | last post by:
Hello, this is something I've been asking myself for sometime ... and now I'd like to clarify this point. When should the try block start in a method??? What I mean is, does having all the code instead of a smaller set of it inside a try clause add any overhead??? 1What I'd like to understand is if, to be completely sure that no unhandles...
2
1490
by: Shi Mu | last post by:
very hard for me to understand the difference between try...except and try...finally
0
7413
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7597
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7752
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7697
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5286
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4902
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3397
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
980
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
650
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.