From 4d51fdbd800ddab8438ef336509b81b4d959a774 Mon Sep 17 00:00:00 2001 From: Frankie Robertson Date: Mon, 9 Jun 2025 00:02:37 +0300 Subject: [PATCH] Make matcher(...) return nothing when no match is found --- src/FileTypes.jl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/FileTypes.jl b/src/FileTypes.jl index 2ae771c..8e83e23 100644 --- a/src/FileTypes.jl +++ b/src/FileTypes.jl @@ -40,9 +40,9 @@ end Args: filename (String) i.e filepath Returns: - FileType.Type object + FileType.Type object or nothing if the file is not recognized """ -function matcher(filename::String)::FileType.Type +function matcher(filename::String)::Union{FileType.Type, Nothing} try if isfile(filename) f=open(filename) @@ -55,6 +55,7 @@ function matcher(filename::String)::FileType.Type end end end + return nothing else throw(error("file not found")) end @@ -106,4 +107,4 @@ function is_mime_supported(mime::MIME)::Bool end export FileType -end \ No newline at end of file +end