Skip to content

Commit

Permalink
Merge pull request #9239 from m-kuhn/better-error-messages-gpkg-fail
Browse files Browse the repository at this point in the history
Better error message when failed to open DB
  • Loading branch information
m-kuhn authored Feb 25, 2019
2 parents 9f576b6 + 1f4747f commit 9834859
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion python/plugins/db_manager/db_plugins/gpkg/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ def _opendb(self):
self.gdal_ds = gdal.OpenEx(self.dbname, gdal.OF_UPDATE)
if self.gdal_ds is None:
self.gdal_ds = gdal.OpenEx(self.dbname)
if self.gdal_ds is None or self.gdal_ds.GetDriver().ShortName != 'GPKG':
if self.gdal_ds is None:
raise ConnectionError(QApplication.translate("DBManagerPlugin", '"{0}" not found').format(self.dbname))
if self.gdal_ds.GetDriver().ShortName != 'GPKG':
raise ConnectionError(QApplication.translate("DBManagerPlugin", '"{dbname}" not recognized as GPKG ({shortname} reported instead.)').format(dbname=self.dbname, shortname=self.gdal_ds.GetDriver().ShortName))
self.has_raster = self.gdal_ds.RasterCount != 0 or self.gdal_ds.GetMetadata('SUBDATASETS') is not None
self.connection = None

Expand Down

0 comments on commit 9834859

Please sign in to comment.