From 524e1b0433474354e2efcd31d16002d5f95394b0 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Fri, 10 Jan 2020 12:15:18 +0100 Subject: [PATCH] Improve error reporting --- src/analysis/processing/qgsalgorithmpackage.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/analysis/processing/qgsalgorithmpackage.cpp b/src/analysis/processing/qgsalgorithmpackage.cpp index 010e695b6c2a..99b756134ec1 100644 --- a/src/analysis/processing/qgsalgorithmpackage.cpp +++ b/src/analysis/processing/qgsalgorithmpackage.cpp @@ -109,12 +109,18 @@ QVariantMap QgsPackageAlgorithm::processAlgorithm( const QVariantMap ¶meters gdal::ogr_datasource_unique_ptr hDS; if ( !QFile::exists( packagePath ) ) + { hDS = gdal::ogr_datasource_unique_ptr( OGR_Dr_CreateDataSource( hGpkgDriver, packagePath.toUtf8().constData(), nullptr ) ); + if ( !hDS ) + throw QgsProcessingException( QObject::tr( "Creation of database %1 failed (OGR error: %2)" ).arg( packagePath, QString::fromUtf8( CPLGetLastErrorMsg() ) ) ); + } else + { hDS = gdal::ogr_datasource_unique_ptr( OGROpen( packagePath.toUtf8().constData(), true, nullptr ) ); + if ( !hDS ) + throw QgsProcessingException( QObject::tr( "Opening database %1 failed (OGR error: %2)" ).arg( packagePath, QString::fromUtf8( CPLGetLastErrorMsg() ) ) ); + } - if ( !hDS ) - throw QgsProcessingException( QObject::tr( "Creation of database failed (OGR error: %1)" ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) ); bool errored = false;