Mercurial > repos > public > sbplib_julia
diff src/Grids/Grids.jl @ 1964:3fb5b03162ee feature/grids/manifolds
Implement an error hint for MethodError with Grids.jacobian
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 11 Feb 2025 15:46:29 +0100 |
parents | 624e19c20c19 |
children | ea04a542a526 |
line wrap: on
line diff
--- a/src/Grids/Grids.jl Tue Feb 11 09:10:19 2025 +0100 +++ b/src/Grids/Grids.jl Tue Feb 11 15:46:29 2025 +0100 @@ -83,4 +83,17 @@ include("zero_dim_grid.jl") include("mapped_grid.jl") +function __init__() + if !isdefined(Base.Experimental, :register_error_hint) + return + end + + Base.Experimental.register_error_hint(MethodError) do io, exc, argtypes, kwargs + if exc.f == Grids.jacobian + print(io, "\nThis possibly means that a function used to define a coordinate mapping is missing a method for `Grids.jacobian`.\n") + print(io, "Provide one by for exmple implementing `Grids.jacobian(::$(typeof(exc.args[1])), x) = ...` or `Grids.jacobian(f, x) = ForwardDiff.jacobian(f,x)`") + end + end +end + end # module