Skip to content

Commit

Permalink
Backport #4928 and #5356
Browse files Browse the repository at this point in the history
  • Loading branch information
tbonfort committed Dec 5, 2016
1 parent a0437f8 commit 022d24b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 26 deletions.
52 changes: 28 additions & 24 deletions mapogr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1118,18 +1118,15 @@ msOGRFileOpen(layerObj *layer, const char *connection )
RELEASE_OGR_LOCK;

if( hDS == NULL ) {
if( strlen(CPLGetLastErrorMsg()) == 0 )
msSetError(MS_OGRERR,
"Open failed for OGR connection in layer `%s'. "
"File not found or unsupported format.",
"msOGRFileOpen()",
layer->name?layer->name:"(null)" );
else
msSetError(MS_OGRERR,
"Open failed for OGR connection in layer `%s'.\n%s\n",
"msOGRFileOpen()",
layer->name?layer->name:"(null)",
CPLGetLastErrorMsg() );
msSetError(MS_OGRERR,
"Open failed for OGR connection in layer `%s'. "
"Check logs.",
"msOGRFileOpen()",
layer->name?layer->name:"(null)" );
if( strlen(CPLGetLastErrorMsg()) != 0 )
msDebug("Open failed for OGR connection in layer `%s'.\n%s\n",
layer->name?layer->name:"(null)",
CPLGetLastErrorMsg() );
CPLFree( pszDSName );
CPLFree( pszLayerDef );
return NULL;
Expand All @@ -1154,10 +1151,13 @@ msOGRFileOpen(layerObj *layer, const char *connection )
ACQUIRE_OGR_LOCK;
hLayer = OGR_DS_ExecuteSQL( hDS, pszLayerDef, NULL, NULL );
if( hLayer == NULL ) {
msSetError(MS_OGRERR,
"ExecuteSQL(%s) failed.\n%s",
"msOGRFileOpen()",
pszLayerDef, CPLGetLastErrorMsg() );
msSetError(MS_OGRERR,
"ExecuteSQL(%s) failed. Check logs",
"msOGRFileOpen()",
pszLayerDef);
msDebug(
"ExecuteSQL(%s) failed.\n%s",
pszLayerDef, CPLGetLastErrorMsg() );
RELEASE_OGR_LOCK;
msConnPoolRelease( layer, hDS );
CPLFree( pszLayerDef );
Expand Down Expand Up @@ -1189,9 +1189,11 @@ msOGRFileOpen(layerObj *layer, const char *connection )
}

if (hLayer == NULL) {
msSetError(MS_OGRERR, "GetLayer(%s) failed for OGR connection `%s'.",
"msOGRFileOpen()",
pszLayerDef, connection );
msSetError(MS_OGRERR, "GetLayer(%s) failed for OGR connection. Check logs.",
"msOGRFileOpen()",
pszLayerDef);
msDebug("GetLayer(%s) failed for OGR connection `%s'.",
pszLayerDef, connection );
CPLFree( pszLayerDef );
msConnPoolRelease( layer, hDS );
return NULL;
Expand Down Expand Up @@ -1353,10 +1355,12 @@ static int msOGRFileWhichShapes(layerObj *layer, rectObj rect,
if( OGR_L_SetAttributeFilter( psInfo->hLayer, layer->filter.string+6 )
!= OGRERR_NONE ) {
msSetError(MS_OGRERR,
"SetAttributeFilter(%s) failed on layer %s.\n%s",
"SetAttributeFilter(%s) failed on layer %s.",
"msOGRFileWhichShapes()",
layer->filter.string+6, layer->name?layer->name:"(null)",
CPLGetLastErrorMsg() );
layer->filter.string+6, layer->name?layer->name:"(null)");
msDebug("SetAttributeFilter(%s) failed on layer %s.\n%s",
layer->filter.string+6, layer->name?layer->name:"(null)",
CPLGetLastErrorMsg() );
RELEASE_OGR_LOCK;
return MS_FAILURE;
}
Expand Down Expand Up @@ -1559,8 +1563,8 @@ msOGRFileNextShape(layerObj *layer, shapeObj *shape,
if( (hFeature = OGR_L_GetNextFeature( psInfo->hLayer )) == NULL ) {
psInfo->last_record_index_read = -1;
if( CPLGetLastErrorType() == CE_Failure ) {
msSetError(MS_OGRERR, "%s", "msOGRFileNextShape()",
CPLGetLastErrorMsg() );
msSetError(MS_OGRERR, "OGR error. check logs", "msOGRFileNextShape()");
msDebug("msOGRFileNextShape() error: %s", CPLGetLastErrorMsg() );
RELEASE_OGR_LOCK;
return MS_FAILURE;
} else {
Expand Down
4 changes: 2 additions & 2 deletions mappostgis.c
Original file line number Diff line number Diff line change
Expand Up @@ -2309,7 +2309,8 @@ int msPostGISLayerOpen(layerObj *layer)
}
}

msSetError(MS_QUERYERR, "Database connection failed (%s) with connect string '%s'\nIs the database running? Is it allowing connections? Does the specified user exist? Is the password valid? Is the database on the standard port?", "msPostGISLayerOpen()", PQerrorMessage(layerinfo->pgconn), maskeddata);
msDebug("Database connection failed (%s) with connect string '%s'\nIs the database running? Is it allowing connections? Does the specified user exist? Is the password valid? Is the database on the standard port?.\n", PQerrorMessage(layerinfo->pgconn), maskeddata);
msSetError(MS_QUERYERR, "Database connection failed.\nIs the database running? Is it allowing connections? Does the specified user exist? Is the password valid? Is the database on the standard port?", "msPostGISLayerOpen()");

if(layerinfo->pgconn) PQfinish(layerinfo->pgconn);
free(maskeddata);
Expand All @@ -2336,7 +2337,6 @@ int msPostGISLayerOpen(layerObj *layer)
* times there will be a leak... */
return MS_FAILURE;
}

}
}

Expand Down

0 comments on commit 022d24b

Please sign in to comment.