Skip to content

Commit

Permalink
a couple of error printing fixes; still repr errors with color codes.
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanKarpinski committed Feb 5, 2013
1 parent 6649a05 commit 1c2388e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion base/error.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ end
print_with_color(color::Symbol, io::IO, msg::String...) =
with_output_color(print, color, io, msg...)
print_with_color(color::Symbol, msg::String...) =
print_with_color(OUTPUT_STREAM, color, msg...)
print_with_color(color, OUTPUT_STREAM, msg...)

# Use colors to print messages and warnings in the REPL
info(msg::String...) = print_with_color(:blue, STDERR, "MESSAGE: ", msg..., "\n")
Expand Down
14 changes: 7 additions & 7 deletions base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,14 @@ function show_unquoted(io::IO, ex::SymbolNode)
show_expr_type(io, ex.typ)
end

print_error(f::Function, io::IO, args...) = with_output_color(:red, io) do io
print("ERROR: ")
f(io, args...)
end
print_error(io::IO, args...) = print_error(print, io, args...)

function show(io::IO, e::TypeError)
with_output_color(:red, io) do io
print_error(io) do io
ctx = isempty(e.context) ? "" : "in $(e.context), "
if e.expected === Bool
print(io, "type error: non-boolean ($(typeof(e.got))) ",
Expand All @@ -329,16 +334,11 @@ function show(io::IO, e::TypeError)
end
end

print_error(f::Function, io::IO, args...) = with_output_color(:red, io) do io
print("ERROR: ")
f(io, args...)
end
print_error(io::IO, args...) = print_error(print, io, args...)

show(io::IO, e::LoadError) = print_error(io) do io
show(io, e.error)
print(io, "\nat $(e.file):$(e.line)")
end

show(io::IO, e::SystemError) = print_error(io, "$(e.prefix): $(strerror(e.errnum))")
show(io::IO, ::DivideByZeroError) = print_error(io, "integer divide by zero")
show(io::IO, ::StackOverflowError) = print_error(io, "stack overflow")
Expand Down

0 comments on commit 1c2388e

Please sign in to comment.