Skip to content

Commit

Permalink
feat: provision for non-verbose safe_get_unit
Browse files Browse the repository at this point in the history
  • Loading branch information
ven-k committed Apr 30, 2024
1 parent 5956a70 commit 77ecabb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/systems/unit_check.jl
Original file line number Diff line number Diff line change
Expand Up @@ -165,17 +165,17 @@ end
"""
Get unit of term, returning nothing & showing warning instead of throwing errors.
"""
function safe_get_unit(term, info)
function safe_get_unit(term, info, verbose=true)
side = nothing
try
side = get_unit(term)
catch err
if err isa DQ.DimensionError
@warn("$info: $(err.x) and $(err.y) are not dimensionally compatible.")
verbose && @warn("$info: $(err.x) and $(err.y) are not dimensionally compatible.")

Check warning on line 174 in src/systems/unit_check.jl

View check run for this annotation

Codecov / codecov/patch

src/systems/unit_check.jl#L174

Added line #L174 was not covered by tests
elseif err isa ValidationError
@warn(info*err.message)
verbose && @warn(info*err.message)
elseif err isa MethodError
@warn("$info: no method matching $(err.f) for arguments $(typeof.(err.args)).")
verbose && @warn("$info: no method matching $(err.f) for arguments $(typeof.(err.args)).")

Check warning on line 178 in src/systems/unit_check.jl

View check run for this annotation

Codecov / codecov/patch

src/systems/unit_check.jl#L178

Added line #L178 was not covered by tests
else
rethrow()
end
Expand Down

0 comments on commit 77ecabb

Please sign in to comment.