Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#4242 closed enhancement (fixed)

[PATCH] Print filename in error messages related to rasterband and datasets

Reported by: landry Owned by: warmerdam
Priority: normal Milestone: 1.9.0
Component: GDAL_Raster Version: unspecified
Severity: normal Keywords:
Cc: warmerdam

Description

I'm doing gdaldem hillshade on a vrt files with a lot of .asc files in it, and one of them is corrupted. Unfortunately, the error message is only : ERROR 3: File short, can't read line 149. ERROR 1: IReadBlock failed at X offset 0, Y offset 149

Messages comes from gcore/gdalrasterband.cpp and frmts/aaigrid/aaigriddataset.cpp, dunno if those files have the current dataset name in their context, but it'd be nice if it also printed it in error messages (at least in the context of vrt files)

Attachments (1)

ticket_4242.patch (28.5 KB) - added by Even Rouault 5 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 5 years ago by Even Rouault

Cc: warmerdam added
Summary: Print filename in error messages when using vrt files[PATCH] Print filename in error messages related to rasterband and datasets

Frank,

what would you think of the attached patch that introduces a ReportError?() method on rasterband and dataset class ? This method has same signature of CPLError(), but just prepends the dataset name (and band number in the case of rasterband) to the error message. As a proof of concept, I've transformed the relevant CPLError() calls of gdalrasterband.cpp and gdaldataset.cpp, but it could also be progressively used by drivers in their derived classes. The main advantage is that it is a way of providing consistant formatting to report dataset/rasterband related errors, while reducing the footprint at each place where we emit the errors.

(It would also have the potential to serve as a centralization point if some day we wanted to provide per-dataset or per-rasterband custom error handlers. But that's more a side-effect.)

Changed 5 years ago by Even Rouault

Attachment: ticket_4242.patch added

comment:2 Changed 5 years ago by warmerdam

LGTM (Looks Good To Me)

comment:3 Changed 5 years ago by Even Rouault

Milestone: 1.9.0
Resolution: fixed
Status: newclosed
Type: defectenhancement

r23077 /trunk/gdal/gcore/ (gdal_priv.h gdaldataset.cpp gdalrasterband.cpp): Add GDALRasterBand::ReportError?() and GDALDataset::ReportError?() to prepend dataset name (and band) before error message (#4242)

r23078 /trunk/gdal/gcore/ (gdaldataset.cpp gdalrasterband.cpp): Convert CPLError() to ReportError?() (#4242)

comment:4 Changed 5 years ago by landry

Thanks for your quick fix!

Note: See TracTickets for help on using tickets.