Skip to content
Permalink
Browse files
allowing unicode error messages
git-svn-id: http://svn.osgeo.org/qgis/trunk@15051 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
brushtyler committed Jan 15, 2011
1 parent 185ec5d commit 8133a995d159973906f1e20901b68537d3af87ed
@@ -32,7 +32,7 @@
from osgeo import gdal
from osgeo import ogr
except ImportError, e:
error_str = str(e)
error_str = e.args[0]
error_mod = error_str.replace( "No module named ", "" )
if req_mods.has_key( error_mod ):
error_str = error_str.replace( error_mod, req_mods[error_mod] )
@@ -181,10 +181,15 @@ def fillVectorOutputFormat(aFilter = None, filename = None):

return shortName

class UnsupportedOGRFormat(Exception):
def __init__(self):
msg = QCoreApplication.translate( "GdalTools", "The selected file is not a supported OGR format" )
Exception.__init__(self, msg)

def getVectorFields(vectorFile):
hds = ogr.Open( unicode(vectorFile).encode('utf8') )
if hds == None:
raise Exception( QCoreApplication.translate( "GdalTools", "The selected file is not a supported OGR format" ) )
raise UnsupportedOGRFormat()

fields = []
names = []
@@ -183,8 +183,8 @@ def loadFields(self, vectorFile = QString()):

try:
(fields, names) = Utils.getVectorFields(vectorFile)
except Exception, e:
QErrorMessage(self).showMessage( str(e) )
except Utils.UnsupportedOGRFormat, e:
QErrorMessage(self).showMessage( e.args[0] )

self.inputLayerCombo.clearEditText()
self.inputLayerCombo.setCurrentIndex(-1)
@@ -104,8 +104,8 @@ def loadFields(self, vectorFile):

try:
(fields, names) = Utils.getVectorFields(vectorFile)
except Exception, e:
QErrorMessage(self).showMessage( str(e) )
except Utils.UnsupportedOGRFormat, e:
QErrorMessage(self).showMessage( e.args[0] )

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

0 comments on commit 8133a99

Please sign in to comment.