[Baypiggies] Crossplatform exceptions.WindowsError help
Paul McNett
p at ulmcnett.com
Mon Apr 14 23:50:30 CEST 2008
Hi,
This code must run cross-platform:
try:
..
except WindowsError:
..
However, the WindowsError exception is only defined on Windows, not on
Linux or Mac. How do I keep a spurious NameError from happening on the
other platforms while still keeping the code clean (free from
os-specific code blocks)?
I'm getting a WindowsError from some users sometimes, when doing
webbrowser.open()[1][2]. I'd like to show a nice message rather then
letting my global error handler kick in, but I have users on all platforms.
Thanks!
Paul
[1] It could be this bug, which I can't seem to open to investigate further:
http://mail.python.org/pipermail/python-bugs-list/2007-March/037608.html
(I get a message "Artifact: This Artifact Has Been Made Private. Only
Group Members Can View Private ArtifactTypes.")
[2] Here's the traceback if you are curious:
"""
Shutter Studio Error Notification
Customer: ----------
License: ----------
User Timestamp: 2008-04-14 21:15:40.187000
Server Timestamp: 2008-04-14 21:15:45.739410
Version, Platform: 0.9.18 Windows-XP-5.1.2600-SP2
Exception Object: [Error 2] The system cannot find the file specified:
u'http://sanbenitoshutter.com'
Exception Type: <type 'exceptions.WindowsError'>
Active Form:
Active Control:
Traceback (most recent call last):
File "dabo\ui\uiwx\dHtmlBox.pyo", line 52, in __onWxLinkClicked
File "dabo\ui\uiwx\dPemMixin.pyo", line 894, in raiseEvent
File "dabo\lib\eventMixin.pyo", line 93, in raiseEvent
File "ss_common\ui\FrmAboutBase.pyo", line 51, in onHtmlLinkClicked
File "webbrowser.pyo", line 60, in open
File "webbrowser.pyo", line 516, in open
<type 'exceptions.WindowsError'>: [Error 2] The system cannot find the
file specified: u'http://sanbenitoshutter.com'
=======================================================
User Notes:
=======================================================
"""
More information about the Baypiggies
mailing list