Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In Julia 1.5 use custom hints to replace debug mode? #144

Open
oxinabox opened this issue Mar 30, 2020 · 0 comments
Open

In Julia 1.5 use custom hints to replace debug mode? #144

oxinabox opened this issue Mar 30, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@oxinabox
Copy link
Member

Right now we use debug mode (#136) with the special error type for addition of composites to primals failing, to give instructions on how to overload things to fix this.
But in julia 1.5 there is special functionality for adding hints for how to resolve errors build in by some magic:
JuliaLang/julia#35094

struct PrimalAdditionFailedException{P} <: Exception
primal::P
differential::Composite{P}
original::Exception
end
function Base.showerror(io::IO, err::PrimalAdditionFailedException{P}) where {P}
println(io, "Could not construct $P after addition.")
println(io, "This probably means no default constructor is defined.")
println(io, "Either define a default constructor")
printstyled(io, "$P(", join(propertynames(err.differential), ", "), ")", color=:blue)
println(io, "\nor overload")
printstyled(io,
"ChainRulesCore.construct(::Type{$P}, ::$(typeof(err.differential)))";
color=:blue
)
println(io, "\nor overload")
printstyled(io, "Base.:+(::$P, ::$(typeof(err.differential)))"; color=:blue)
println(io, "\nOriginal Exception:")
printstyled(io, err.original; color=:yellow)
println(io)
end

@oxinabox oxinabox added the enhancement New feature or request label Mar 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant