Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specific file listed in errors? #96

Closed
rafaqz opened this issue Oct 12, 2020 · 5 comments
Closed

Specific file listed in errors? #96

rafaqz opened this issue Oct 12, 2020 · 5 comments

Comments

@rafaqz
Copy link
Member

rafaqz commented Oct 12, 2020

It would be nice if an error like this reported the file name in question:

ERROR: GDALError (CE_Failure, code 3):
        File short, can't read line 204.

Especially when looping over large datasets with hundreds of files. I'm not sure how easy that is to do or where to do it exactly - this could be something for ArchGDAL.jl

@rafaqz rafaqz changed the title More informative errors? Specific file listed in errors? Oct 12, 2020
@visr
Copy link
Member

visr commented Oct 12, 2020

Yeah it's unfortunate that the file name is not mentioned here.

In this package we hook onto the error handler of GDAL, using the API GDAL provides for that.

The source code for that is here: https://github.com/JuliaGeo/GDAL.jl/blob/79560db2e494dd41c800df30ee8ab26384360a5c/src/error.jl
And we hook this in during module load:

GDAL.jl/src/GDAL.jl

Lines 36 to 38 in 79560db

# register custom error handler
funcptr = @cfunction(gdaljl_errorhandler, Ptr{Cvoid}, (CPLErr, Cint, Cstring))
cplseterrorhandler(funcptr)

So the message that you are seeing is not coming from this package, but from GDAL itself. So the best location to improve this would be in GDAL, you could submit an issue here: https://github.com/OSGeo/gdal. ArchGDAL is using the same error handling. I think it would make it unneccesarily complicated if we were to try to augment some of the error messages that we deem not good enough. This error is thrown because GDAL decides it wants to throw an error. That gets caught in our error callback.

@rafaqz
Copy link
Member Author

rafaqz commented Oct 13, 2020

Sure I get that GDALerror works like that. But at some point in the chain someone should improve the errors. I'll try gdal directly and see how it goes.

@visr
Copy link
Member

visr commented Oct 13, 2020

Looks like this comes from https://github.com/OSGeo/gdal/blob/20d44a181f73b87ebb7c1660498bb9e78e572e54/gdal/frmts/aaigrid/aaigriddataset.cpp#L187, so the AAIGrid driver. We're using a somewhat older GDAL version at the moment, 3.0.4, but it's the same in GDAL master.

Grepping CPLError(CE_Failure, CPLE_FileIO it seems most IO errors don't report the file name, except for instance: CPLError(CE_Failure, CPLE_FileIO, "Cannot create %s", pszFilename);.

@rafaqz
Copy link
Member Author

rafaqz commented Oct 13, 2020

They literally fixed it already: OSGeo/gdal#3054

@rafaqz rafaqz closed this as completed Oct 13, 2020
@visr
Copy link
Member

visr commented Oct 13, 2020

Gotta love Even's dedication :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants