Skip to content

Commit e8ffb0b

Browse files
author
brushtyler
committedJan 15, 2011
allowing unicode error messages
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15051 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent af87923 commit e8ffb0b

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed
 

‎python/plugins/GdalTools/GdalTools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from osgeo import gdal
3333
from osgeo import ogr
3434
except ImportError, e:
35-
error_str = str(e)
35+
error_str = e.args[0]
3636
error_mod = error_str.replace( "No module named ", "" )
3737
if req_mods.has_key( error_mod ):
3838
error_str = error_str.replace( error_mod, req_mods[error_mod] )

‎python/plugins/GdalTools/tools/GdalTools_utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,15 @@ def fillVectorOutputFormat(aFilter = None, filename = None):
181181

182182
return shortName
183183

184+
class UnsupportedOGRFormat(Exception):
185+
def __init__(self):
186+
msg = QCoreApplication.translate( "GdalTools", "The selected file is not a supported OGR format" )
187+
Exception.__init__(self, msg)
188+
184189
def getVectorFields(vectorFile):
185190
hds = ogr.Open( unicode(vectorFile).encode('utf8') )
186191
if hds == None:
187-
raise Exception( QCoreApplication.translate( "GdalTools", "The selected file is not a supported OGR format" ) )
192+
raise UnsupportedOGRFormat()
188193

189194
fields = []
190195
names = []

‎python/plugins/GdalTools/tools/doGrid.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ def loadFields(self, vectorFile = QString()):
183183

184184
try:
185185
(fields, names) = Utils.getVectorFields(vectorFile)
186-
except Exception, e:
187-
QErrorMessage(self).showMessage( str(e) )
186+
except Utils.UnsupportedOGRFormat, e:
187+
QErrorMessage(self).showMessage( e.args[0] )
188188

189189
self.inputLayerCombo.clearEditText()
190190
self.inputLayerCombo.setCurrentIndex(-1)

‎python/plugins/GdalTools/tools/doRasterize.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ def loadFields(self, vectorFile):
104104

105105
try:
106106
(fields, names) = Utils.getVectorFields(vectorFile)
107-
except Exception, e:
108-
QErrorMessage(self).showMessage( str(e) )
107+
except Utils.UnsupportedOGRFormat, e:
108+
QErrorMessage(self).showMessage( e.args[0] )
109109

110110
self.inputLayerCombo.clearEditText()
111111
self.inputLayerCombo.setCurrentIndex(-1)

0 commit comments

Comments
 (0)