Arrange public/private sections in Display
This commit is contained in:
@@ -11,18 +11,8 @@ defmodule Display do
|
|||||||
IO.puts(format_failure(failure))
|
IO.puts(format_failure(failure))
|
||||||
end
|
end
|
||||||
|
|
||||||
def format_failure(%ExUnit.AssertionError{expr: expr}) do
|
def show_compile_error(error) do
|
||||||
"""
|
format_error(error) |> IO.puts
|
||||||
#{format_cyan("Assertion failed in #{last_failure_location}")}
|
|
||||||
#{format_red(Macro.to_string(expr))}
|
|
||||||
"""
|
|
||||||
end
|
|
||||||
|
|
||||||
def format_failure(error) do
|
|
||||||
"""
|
|
||||||
#{format_cyan("Error in #{last_failure_location}")}
|
|
||||||
#{format_error(error)}
|
|
||||||
"""
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def considering(module) do
|
def considering(module) do
|
||||||
@@ -36,7 +26,21 @@ defmodule Display do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def last_failure_location do
|
defp format_failure(%ExUnit.AssertionError{expr: expr}) do
|
||||||
|
"""
|
||||||
|
#{format_cyan("Assertion failed in #{last_failure_location}")}
|
||||||
|
#{format_red(Macro.to_string(expr))}
|
||||||
|
"""
|
||||||
|
end
|
||||||
|
|
||||||
|
defp format_failure(error) do
|
||||||
|
"""
|
||||||
|
#{format_cyan("Error in #{last_failure_location}")}
|
||||||
|
#{format_error(error)}
|
||||||
|
"""
|
||||||
|
end
|
||||||
|
|
||||||
|
defp last_failure_location do
|
||||||
{file, line} = System.stacktrace
|
{file, line} = System.stacktrace
|
||||||
|> Enum.drop_while(&in_ex_unit?/1)
|
|> Enum.drop_while(&in_ex_unit?/1)
|
||||||
|> List.first
|
|> List.first
|
||||||
@@ -52,11 +56,7 @@ defmodule Display do
|
|||||||
{file, line}
|
{file, line}
|
||||||
end
|
end
|
||||||
|
|
||||||
def format_compile_error(error) do
|
defp format_error(error) do
|
||||||
format_error(error) |> IO.puts
|
|
||||||
end
|
|
||||||
|
|
||||||
def format_error(error) do
|
|
||||||
trace = System.stacktrace |> Enum.take(2)
|
trace = System.stacktrace |> Enum.take(2)
|
||||||
format_red(Exception.format(:error, error, trace))
|
format_red(Exception.format(:error, error, trace))
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ defmodule Watcher do
|
|||||||
[{mod, _} | _] = Code.load_file(file)
|
[{mod, _} | _] = Code.load_file(file)
|
||||||
Runner.run(mod)
|
Runner.run(mod)
|
||||||
rescue
|
rescue
|
||||||
e -> Display.format_compile_error(e)
|
e -> Display.show_compile_error(e)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user