Skip to content

Commit

Permalink
Move silence errors to midlevel and remove straggling definition of r…
Browse files Browse the repository at this point in the history
…ehash (#810)

* Move silence_errors to mid level

* Remove rehash definition that JLD no longer needs

* Update src/api_midlevel.jl

Co-authored-by: jmert <[email protected]>

Co-authored-by: jmert <[email protected]>
  • Loading branch information
musm and jmert authored Jan 19, 2021
1 parent 6883d9d commit 0d13166
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
15 changes: 0 additions & 15 deletions src/HDF5.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1966,21 +1966,6 @@ function create_external(source::Union{File,Group}, source_relpath, target_filen
nothing
end

# error handling
function silence_errors(f::Function)
estack = H5E_DEFAULT
func, client_data = h5e_get_auto(estack)
h5e_set_auto(estack, C_NULL, C_NULL)
try
return f()
finally
h5e_set_auto(estack, func, client_data)
end
end

# Define globally because JLD uses this, too
const rehash! = Base.rehash!

# Across initializations of the library, the id of various properties
# will change. So don't hard-code the id (important for precompilation)
const UTF8_LINK_PROPERTIES = Ref{Properties}()
Expand Down
16 changes: 16 additions & 0 deletions src/api_midlevel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,19 @@ function get_extent_dims(obj::Union{Dataspace,Dataset,Attribute})
obj isa Dataspace || close(dspace)
return dims, maxdims
end

"""
silence_errors(f::Function)
During execution of the function `f`, disable printing of internal HDF5 library error messages.
"""
function silence_errors(f::Function)
estack = H5E_DEFAULT
func, client_data = h5e_get_auto(estack)
h5e_set_auto(estack, C_NULL, C_NULL)
try
return f()
finally
h5e_set_auto(estack, func, client_data)
end
end

0 comments on commit 0d13166

Please sign in to comment.