Skip to content
Permalink
Browse files

log OGR errors in QgsVectorFileWriter::addFeature

  • Loading branch information
jef-n committed May 26, 2012
1 parent 7a29f3c commit c7f341e7794e4ed07e6456252913f7da0203b940
Showing with 7 additions and 5 deletions.
  1. +7 −5 src/core/qgsvectorfilewriter.cpp
@@ -21,6 +21,7 @@
#include "qgsfeature.h"
#include "qgsgeometry.h"
#include "qgslogger.h"
#include "qgsmessagelog.h"
#include "qgscoordinatereferencesystem.h"
#include "qgsvectorfilewriter.h"

@@ -468,7 +469,7 @@ bool QgsVectorFileWriter::addFeature( QgsFeature& feature )
.arg( ogrField )
.arg( QMetaType::typeName( attrValue.type() ) )
.arg( attrValue.toString() );
QgsDebugMsg( mErrorMessage );
QgsMessageLog::logMessage( mErrorMessage, QObject::tr( "OGR" ) );
mError = ErrFeatureWriteFailed;
return false;
}
@@ -493,21 +494,21 @@ bool QgsVectorFileWriter::addFeature( QgsFeature& feature )

if ( !mGeom2 )
{
QgsDebugMsg( QString( "Failed to create empty geometry for type %1 (OGR error: %2)" ).arg( geom->wkbType() ).arg( CPLGetLastErrorMsg() ) );
mErrorMessage = QObject::tr( "Feature geometry not imported (OGR error: %1)" )
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ) );
mError = ErrFeatureWriteFailed;
QgsMessageLog::logMessage( mErrorMessage, QObject::tr( "OGR" ) );
OGR_F_Destroy( poFeature );
return false;
}

OGRErr err = OGR_G_ImportFromWkb( mGeom2, geom->asWkb(), geom->wkbSize() );
if ( err != OGRERR_NONE )
{
QgsDebugMsg( QString( "Failed to import geometry from WKB: %1 (OGR error: %2)" ).arg( err ).arg( CPLGetLastErrorMsg() ) );
mErrorMessage = QObject::tr( "Feature geometry not imported (OGR error: %1)" )
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ) );
mError = ErrFeatureWriteFailed;
QgsMessageLog::logMessage( mErrorMessage, QObject::tr( "OGR" ) );
OGR_F_Destroy( poFeature );
return false;
}
@@ -520,10 +521,10 @@ bool QgsVectorFileWriter::addFeature( QgsFeature& feature )
OGRErr err = OGR_G_ImportFromWkb( mGeom, geom->asWkb(), geom->wkbSize() );
if ( err != OGRERR_NONE )
{
QgsDebugMsg( QString( "Failed to import geometry from WKB: %1 (OGR error: %2)" ).arg( err ).arg( CPLGetLastErrorMsg() ) );
mErrorMessage = QObject::tr( "Feature geometry not imported (OGR error: %1)" )
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ) );
mError = ErrFeatureWriteFailed;
QgsMessageLog::logMessage( mErrorMessage, QObject::tr( "OGR" ) );
OGR_F_Destroy( poFeature );
return false;
}
@@ -539,7 +540,8 @@ bool QgsVectorFileWriter::addFeature( QgsFeature& feature )
mErrorMessage = QObject::tr( "Feature creation error (OGR error: %1)" ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) );
mError = ErrFeatureWriteFailed;

QgsDebugMsg( mErrorMessage );
QgsMessageLog::logMessage( mErrorMessage, QObject::tr( "OGR" ) );

OGR_F_Destroy( poFeature );
return false;
}

0 comments on commit c7f341e

Please sign in to comment.
You can’t perform that action at this time.