Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/parser_api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@ function ParseError(stream::ParseStream; incomplete_tag=:none, kws...)
end

function Base.showerror(io::IO, err::ParseError)
println(io, "ParseError:")
# Only show the first parse error for now - later errors are often
# misleading due to the way recovery works
i = findfirst(is_error, err.diagnostics)
if isnothing(i)
i = lastindex(err.diagnostics)
level_info = " some warnings detected:"
else
level_info = ""
end
println(io, "ParseError:", level_info)
show_diagnostics(io, err.diagnostics[1:i], err.source)
end

Expand Down
2 changes: 1 addition & 1 deletion test/hooks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ end
if JuliaSyntax._has_v1_10_hooks
@test err.args[1] isa Meta.ParseError
exc = err.args[1]
@test exc.msg == "ParseError:\n# Error @ none:1:2\n\"\n#└ ── unterminated string literal"
@test exc.msg == "ParseError\n# Error @ none:1:2\n\"\n#└ ── unterminated string literal"
@test exc.detail isa JuliaSyntax.ParseError
@test exc.detail.incomplete_tag === :string
else
Expand Down
2 changes: 1 addition & 1 deletion test/parser_api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ end
catch exc
@test exc isa JuliaSyntax.ParseError
@test sprint(showerror, exc) == """
ParseError:
ParseError: some warnings detected:
# Warning @ somefile.jl:1:2
@(a)
#└─┘ ── parenthesizing macro names is unnecessary"""
Expand Down