Skip to content

Commit

Permalink
better error message for non-regognized time units
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Barth committed Dec 7, 2023
1 parent e071e97 commit 694e353
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/cfvariable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,15 @@ function cfvariable(ds,
time_origin,time_factor = CFTime.timeunits(units, calendar)
catch err
calendar = nothing
@warn(sprint(showerror,err))
@debug "time units parsing failed " err units calendar

message = (
"cannot parse time units `$units`",
(isnothing(calendar) ? "" : " (calendar `$calendar`)"),
": ",
sprint(showerror,err))

@warn(join(message))
end
end

Expand Down
4 changes: 3 additions & 1 deletion test/test_scaling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,6 @@ show(io,md.dim)
str = String(take!(io))
@test occursin("lon",str)

#close(md)
@test_logs (:warn, r".*analysis.*") CDM.defVar(md,"data2",eltype(data),("lon","lat"), attrib = OrderedDict{String,Any}( "units" => "days since analysis"));

close(md)

0 comments on commit 694e353

Please sign in to comment.