From 694e3531ed960a8026f5b682990a11bf4de09cf4 Mon Sep 17 00:00:00 2001 From: Alexander Barth Date: Thu, 7 Dec 2023 11:07:58 +0100 Subject: [PATCH] better error message for non-regognized time units --- src/cfvariable.jl | 10 +++++++++- test/test_scaling.jl | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/cfvariable.jl b/src/cfvariable.jl index 4860f78..f68da90 100644 --- a/src/cfvariable.jl +++ b/src/cfvariable.jl @@ -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 diff --git a/test/test_scaling.jl b/test/test_scaling.jl index 20f33e2..aa9b4ad 100644 --- a/test/test_scaling.jl +++ b/test/test_scaling.jl @@ -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)