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

Printing of error in doctest #653

Closed
fredrikekre opened this issue Mar 1, 2018 · 3 comments
Closed

Printing of error in doctest #653

fredrikekre opened this issue Mar 1, 2018 · 3 comments
Milestone

Comments

@fredrikekre
Copy link
Member

The following doctest, taken from julia base

```jldoctest
julia> struct MyException <: Exception
           msg::AbstractString
       end

julia> function Base.showerror(io::IO, err::MyException)
           print(io, "MyException: ")
           print(io, err.msg)
       end

julia> err = MyException("test exception")
MyException("test exception")

julia> sprint(showerror, err)
"MyException: test exception"

julia> throw(MyException("test exception"))
ERROR: MyException: test exception
```

fails on the last expression. Instead of ERROR: MyException: test exception Documenter evaluates to MyException("test exception") so somehow we never end up in the custom showerror function.

@fredrikekre
Copy link
Member Author

Probably some logic that is incorrect here

function error_to_string(buf, er, bt)
fs = funcsym()
# Remove unimportant backtrace info.
index = Compat.findlast(ptr -> Documenter.ip_matches_func(ptr, fs), bt)
# Print a REPL-like error message.
disable_color() do
print(buf, "ERROR: ")
showerror(buf, er, index === nothing ? bt : bt[1:(index - 1)])
end
sanitise(buf)
end

@mortenpi
Copy link
Member

mortenpi commented Mar 1, 2018

It's not related to world-age stuff by any chance? showerror might need Base.invokelatest?

@fredrikekre
Copy link
Member Author

Ah, good catch! That fixes it.

@mortenpi mortenpi added this to the 0.14.0 milestone Mar 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants