Why does try\catch not work in this example?

julia> using PlotlyLight

julia> try
       catch e
           @warn "NaN in plot"
Error showing value of type Plot:
ERROR: NaN not allowed to be written in JSON spec
1 Like

Probably because the Plot() call does not throw. The try/catch block returns a Plot, which Julia then tries to show; that is when the exception is thrown.

I don’t know how PlotlyLight works, but it’s possible that trying Plot(y=[NaN,NaN]) |> display will throw.