473,805 Members | 1,882 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Catching exception information from ExpatError

Hey
Straightforward question:
I'm opening an xml file with minidom.

When I have a mismatch in the XML file, I simply want my python script to
not only stop gracefully, but also to call up UltraEdit with that xml file,
and highlighting the offending line (keep in mind UEdit can take command
line argument with the row and column)

When I let the exception be caught by default, I notice that I get:
xml.parsers.exp at.ExpatError: mismatched tag: line 19, column 7

But when I catch the error with: except exp.ExpatError:
and then get the information from sys.exc_info(), it returns a tuple that
doesn't help:

class xml.parsers.exp at.ExpatError at 0x00F7FF90>,
<xml.parsers.ex pat.ExpatError instance at 0x00FFD800>, <traceback object at
0x00FFD8C8>)
I want to somehow get the more useful: "line 19, column 7" and parse that
and call ultraedit with the 19 and the 7.

Can you suggest something, is it obvious?
thanks
Steve


Jul 18 '05 #1
3 3662
python newbie wrote:
Can you suggest something, is it obvious?


It is.

http://www.python.org/doc/current/li...r-objects.html
--
Regards,

Diez B. Roggisch
Jul 18 '05 #2
Thanks Diez,
I'll make that the first site that I visit when I have questions, as well.
"Diez B. Roggisch" <no**********@w eb.de> wrote in message
news:c1******** *****@ID-111250.news.uni-berlin.de...
python newbie wrote:
Can you suggest something, is it obvious?


It is.

http://www.python.org/doc/current/li...r-objects.html
--
Regards,

Diez B. Roggisch

Jul 18 '05 #3
> Thanks Diez,
I'll make that the first site that I visit when I have questions, as
well.


Good decision - the nice thing on python is thats more or less everything
you want to know is already out there - and especially on python.org ;)

--
Regards,

Diez B. Roggisch
Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3975
by: mirandacascade | last post by:
Verion of Python: 2.4 O/S: Windows XP ElementTree resides in the c:\python24\lib\site-packages\elementtree\ folder When a string that does not contain well-formed XML is passed as an argument to the XML() method in ElementTree.py, an ExpatError exception is raised. I can trap the exception with a try/except where the except does not specify a specific exception, but I cannot figure out how to construct the except clause in a...
3
1814
by: Manish Soni | last post by:
Hi, A module which I am calling may have a run time error. Now currently in such case user gets message box saying run time error has occured. My aim is to catch this runtime error and show a friendly message to the user. How can this be done? I have tried putting a try catch block around function call but runtime error is not caught. --Manish Soni
7
2343
by: cmay | last post by:
FxCop complains every time I catch System.Exception. I don't see the value in trying to catch every possible exception type (or even figuring out what exceptions can be caught) by a given block of code, when System.Exception seems to get the job done for me. My application is an ASP.Net intranet site. When I catch an exception, I log the stack trace and deal with it, normally by displaying an error
12
6121
by: Vasco Lohrenscheit | last post by:
Hi, I have a Problem with unmanaged exception. In the debug build it works fine to catch unmanaged c++ exceptions from other dlls with //managed code: try { //the form loads unmanaged dlls out of which unmanaged exception //get thrown
2
1309
by: Eric Sabine | last post by:
I built a generic exception handler form which allows the user to get information from it, print it, email it, etc. for exceptions for which I explicitly didn't handle in code, such as missing permissions on a stored procedure, etc. I use this exception handler in all of my applications and it can be called as simply as follows try ... catch ex as sqlexception ExceptionHandler(ex, otherData1, otherData2)
1
3138
by: Atara | last post by:
My application starts with: Module mmcMain Public Sub Main() Debug.WriteLine("Main begin") Dim splashForm As New mcDlgs.cmcDlgSplash2 splashForm.Show() ....
3
5568
by: Shuaib | last post by:
Hey! I am getting this exception. xml.parsers.expat.ExpatError But I am not able to catch it with "except xml.parsers.expat.ExpatError:" It says "NameError: global name 'xml' is not defined".
2
1474
by: Paolo | last post by:
Hello Everybody! Considering this code: try { ExecuteOperation(); } catch {
3
3290
by: john | last post by:
I wrapped some fortran code using F2PY and need to be able to catch fortran runtime errors to run the following: # "grid" is a wrapped fortran module # no runtime errors incurred when run with the correct inputs for filetype #------------------------------- def readGrid( self, coord='xyz' ): mg = ( '.FALSE.', '.TRUE.' ) form = ( 'FORMATTED', 'UNFORMATTED' )
0
9716
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
10360
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...
1
10366
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10105
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
9185
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
7646
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
5542
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3845
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3007
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.