Skip to content

Commit

Permalink
sightly better exception handling
Browse files Browse the repository at this point in the history
still much todo.
E.g. have a `CanNotLoad` exception, or `NotInstalled`.
  • Loading branch information
SimonDanisch committed Sep 24, 2015
1 parent 0ec071b commit 519f950
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/FileIO.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,12 @@ the magic bytes are essential.
function load(s::@compat(Union{AbstractString,IO}), args...; options...)
q = query(s)
libraries = applicable_loaders(q)

last_exception = ErrorException("No library available to load $s")
for library in libraries
try
check_loader(library)
return load(q, args...; options...)
catch e
warn(e)
last_exception = e
end
end
Expand All @@ -74,14 +73,13 @@ trying to infer the format from `filename`.
function save(s::@compat(Union{AbstractString,IO}), data...; options...)
q = query(s)
libraries = applicable_savers(q)
last_exception = ErrorException("No library available to save $s")
for library in libraries
try
println(library)
check_saver(library)
return save(q, data...; options...)
catch e
warn(e)
last_exception = e
last_exception = e #TODO, better and standardized exception propagation system
end
end
rethrow(last_exception)
Expand Down

0 comments on commit 519f950

Please sign in to comment.