Opened 11 years ago

Closed 11 years ago

Last modified 11 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


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 11 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 by Even Rouault, 11 years ago

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


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.)

by Even Rouault, 11 years ago

Attachment: ticket_4242.patch added

comment:2 by warmerdam, 11 years ago

LGTM (Looks Good To Me)

comment:3 by Even Rouault, 11 years ago

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 by landry, 11 years ago

Thanks for your quick fix!

Note: See TracTickets for help on using tickets.