Skip to content

Commit f6ed8d8

Browse files
committed
Make findfirst return nothing instead of erroring.
1 parent d12fac6 commit f6ed8d8

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

src/Abstract/Section.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,7 @@ Return the first section that matches on of the given `names`.
101101
"""
102102
function findfirst(sections::Sections, names::Vector{String})
103103
results = findall(sections, names)
104-
if isempty(results)
105-
error("Could not find any sections that match $(names)")
106-
end
104+
isempty(results) && return nothing
107105
return first(results)
108106
end
109107

src/Abstract/Symbol.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,7 @@ Return the first section that matches on of the given `names`.
101101
"""
102102
function findfirst(symbols::Symbols, names::Vector{String})
103103
results = findall(symbols, names)
104-
if isempty(results)
105-
error("Could not find any symbols that match $(names)")
106-
end
104+
isempty(results) && return nothing
107105
return first(results)
108106
end
109107

0 commit comments

Comments
 (0)