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

Friendlier error messages when file not found #49

Open
niclasmattsson opened this issue Apr 25, 2023 · 3 comments
Open

Friendlier error messages when file not found #49

niclasmattsson opened this issue Apr 25, 2023 · 3 comments

Comments

@niclasmattsson
Copy link

This is an upstream problem in ArchGDAL but I'm opening it here (since this package seems to be aimed at making ArchGDAL's weird pointer-based types friendlier to work with). Here's the problem in a nutshell:

julia> gdf = GDF.read("doesnt_exist.gpkg")
ERROR: GDALError (CE_Failure, code 10):
        Pointer 'hDS' is NULL in 'GDALDatasetH'.

Could we have read() check if a file exists before passing it on to ArchGDAL, and throw a friendlier error message if it doesn't exist?

@visr
Copy link
Collaborator

visr commented May 6, 2023

I agree this is not a great error message. It comes directly from GDAL, and we probably catch it in GDAL.jl using out custom error handler: https://github.com/JuliaGeo/GDAL.jl/blob/v1.5.1/src/error.jl#L49-L63

Doing an isfile(path) before handing it to GDAL prevents us from using URLs or virtual file systems however, so I don't see that working.

Only thing I can think of is to perhaps avoid the GDAL.jl aftercare function called in https://github.com/yeesian/ArchGDAL.jl/blob/v0.10.1/src/dataset.jl#L536 (and similar), and instead directly use ccall. That would have to be done in ArchGDAL.jl

@evetion
Copy link
Owner

evetion commented May 10, 2023

Do you have the latest version installed? I fixed that in v0.3.2, some months back.

julia> gdf = GeoDataFrames.read("doesnt_exist.gpkg")
ERROR: File not found.
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] read(fn::String; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ GeoDataFrames ~/.julia/packages/GeoDataFrames/pHXgK/src/io.jl:32
 [3] read(fn::String)
   @ GeoDataFrames ~/.julia/packages/GeoDataFrames/pHXgK/src/io.jl:31
 [4] top-level scope
   @ REPL[4]:1

@alex-s-gardner
Copy link

Can this be closed?

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

4 participants