Mercurial > repos > public > sbplib_julia
comparison 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 |
comparison
equal
deleted
inserted
replaced
1963:624e19c20c19 | 1964:3fb5b03162ee |
---|---|
81 include("tensor_grid.jl") | 81 include("tensor_grid.jl") |
82 include("equidistant_grid.jl") | 82 include("equidistant_grid.jl") |
83 include("zero_dim_grid.jl") | 83 include("zero_dim_grid.jl") |
84 include("mapped_grid.jl") | 84 include("mapped_grid.jl") |
85 | 85 |
86 function __init__() | |
87 if !isdefined(Base.Experimental, :register_error_hint) | |
88 return | |
89 end | |
90 | |
91 Base.Experimental.register_error_hint(MethodError) do io, exc, argtypes, kwargs | |
92 if exc.f == Grids.jacobian | |
93 print(io, "\nThis possibly means that a function used to define a coordinate mapping is missing a method for `Grids.jacobian`.\n") | |
94 print(io, "Provide one by for exmple implementing `Grids.jacobian(::$(typeof(exc.args[1])), x) = ...` or `Grids.jacobian(f, x) = ForwardDiff.jacobian(f,x)`") | |
95 end | |
96 end | |
97 end | |
98 | |
86 end # module | 99 end # module |