Skip to content

Commit f06cdfd

Browse files
Merge pull request #9 from frankier/matcher-nothing
Make matcher(...) return nothing when no match is found
2 parents c641c2e + 4d51fdb commit f06cdfd

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/FileTypes.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ end
4040
Args:
4141
filename (String) i.e filepath
4242
Returns:
43-
FileType.Type object
43+
FileType.Type object or nothing if the file is not recognized
4444
"""
45-
function matcher(filename::String)::FileType.Type
45+
function matcher(filename::String)::Union{FileType.Type, Nothing}
4646
try
4747
if isfile(filename)
4848
f=open(filename)
@@ -55,6 +55,7 @@ function matcher(filename::String)::FileType.Type
5555
end
5656
end
5757
end
58+
return nothing
5859
else
5960
throw(error("file not found"))
6061
end
@@ -106,4 +107,4 @@ function is_mime_supported(mime::MIME)::Bool
106107
end
107108

108109
export FileType
109-
end
110+
end

0 commit comments

Comments
 (0)