How To Reference An Exception Class In Python?
I want to catch a GPSException thrown by the gpxpy library. try: gpx = gpxpy.parse(open(filepath)) except GPXException: print 'GPXException for %s.' % filepath Since I am
Solution 1:
You need to reference the exception correctly.
Either import the exception directly into your module, or use the full reference:
import gpxpy.gpx
try:
# ...except gpxpy.gpx.GPSException:
# ...
or
Baca Juga
- Raise Imgurclienterror('json Decoding Of Response Failed.') Imgurpython.helpers.error.imgurclienterror: Json Decoding Of Response Failed
- Requests Module Missingschema Error In Tkinter Gui Due To Inability To Fill Variable Before Execution Of Mainloop: How To Resolve This?
- How To Reference An Exception Class In Python?
from gpxpy.gpx import GPSException
try:
# ...except GPSException:
# ...
Post a Comment for "How To Reference An Exception Class In Python?"