Skip to content

Commit 3ae36a8

Browse files
committed
Merge pull request #54 from JuliaIO/teh/load_error
Clarify load errors
2 parents 8e6b433 + 6b062e3 commit 3ae36a8

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

src/FileIO.jl

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,6 @@ include("error_handling.jl")
4343
include("loadsave.jl")
4444
include("registry.jl")
4545

46-
47-
end # module
48-
49-
if VERSION < v"0.4.0-dev"
50-
using Docile
51-
end
52-
5346
@doc """
5447
`FileIO` API (brief summary, see individual functions for more detail):
5548
@@ -73,3 +66,5 @@ end
7366
- `add_loader(fmt, :Package)`: indicate that `Package` supports loading files of type `fmt`
7467
- `add_saver(fmt, :Package)`: indicate that `Package` supports saving files of type `fmt`
7568
""" -> FileIO
69+
70+
end

src/loadsave.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ trying to infer the format from `filename`.
4949
- `save(Stream(format"PNG",io), data...)` specifies the format directly, and bypasses inference.
5050
- `save(f, data...; options...)` passes keyword arguments on to the saver.
5151
""" ->
52-
save(s::@compat(Union{AbstractString,IO}), data...; options...) =
52+
save(s::@compat(Union{AbstractString,IO}), data...; options...) =
5353
save(query(s), data...; options...)
5454

5555
# Forced format
@@ -68,7 +68,10 @@ end
6868

6969
# Fallbacks
7070
function load{F}(q::Formatted{F}, args...; options...)
71-
unknown(q) && throw(UnknownFormat(q))
71+
if unknown(q)
72+
isfile(filename(q)) || open(filename(q)) # force systemerror
73+
throw(UnknownFormat(q))
74+
end
7275
libraries = applicable_loaders(q)
7376
failures = Any[]
7477
for library in libraries

test/loadsave.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,7 @@ context("Ambiguous extension") do
174174

175175
rm(fn)
176176
end
177+
178+
context("Absent file") do
179+
@fact_throws SystemError load("nonexistent.oops")
180+
end

0 commit comments

Comments
 (0)