473,608 Members | 2,410 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 52001

"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
6038
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
2470
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
3808
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
3379
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 would go something like try
3
2195
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
3014
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 model (specifically, exceptions). Without fail, when I start talking with some of the "old-timers"...
4
2443
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
2241
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
2018
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 exception will get to the user, I can place all the code inside a try block and if this practice...
2
1493
by: Shi Mu | last post by:
very hard for me to understand the difference between try...except and try...finally
0
8067
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8501
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8483
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8349
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6820
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6015
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5479
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2477
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1607
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.