Write exception details using UI.error, and UI.error will now output "ERROR:" in red!
This commit is contained in:
parent
5573e0d221
commit
20dd08e977
11
lib/guard.rb
11
lib/guard.rb
@ -59,13 +59,12 @@ module Guard
|
||||
# fire it if his work leads to a system failure
|
||||
def supervised_task(guard, task_to_supervise, *args)
|
||||
guard.send(task_to_supervise, *args)
|
||||
rescue Exception => err
|
||||
UI.error("#{guard.class.name} guard failed to achieve its <#{task_to_supervise.to_s}> command: #{err}")
|
||||
warn "#{err.class}: #{err.message}"
|
||||
warn err.backtrace.join("\n")
|
||||
rescue Exception => ex
|
||||
UI.error("#{guard.class.name} failed to achieve its <#{task_to_supervise.to_s}>, exception was:" +
|
||||
"\n#{ex.class}: #{ex.message}\n#{ex.backtrace.join("\n")}")
|
||||
guards.delete guard
|
||||
UI.info("Guard #{guard.class.name} has just been fired")
|
||||
return err
|
||||
UI.info("\n#{guard.class.name} has just been fired")
|
||||
return ex
|
||||
end
|
||||
|
||||
def run
|
||||
|
@ -12,7 +12,7 @@ module Guard
|
||||
def error(message, options = {})
|
||||
unless ENV["GUARD_ENV"] == "test"
|
||||
reset_line if options[:reset]
|
||||
puts "ERROR: #{message}"
|
||||
puts "#{color('ERROR:', ';31')} #{message}"
|
||||
end
|
||||
end
|
||||
|
||||
@ -24,11 +24,7 @@ module Guard
|
||||
end
|
||||
|
||||
def reset_line
|
||||
if color_enabled?
|
||||
print "\r\e[0m"
|
||||
else
|
||||
print "\r\n"
|
||||
end
|
||||
print(color_enabled? ? "\r\e[0m" : "\r\n")
|
||||
end
|
||||
|
||||
def clear
|
||||
@ -38,15 +34,11 @@ module Guard
|
||||
private
|
||||
|
||||
def reset_color(text)
|
||||
color(text, "\e[0m")
|
||||
color(text, "")
|
||||
end
|
||||
|
||||
def color(text, color_code)
|
||||
if color_enabled?
|
||||
"#{color_code}#{text}\e[0m"
|
||||
else
|
||||
text
|
||||
end
|
||||
color_enabled? ? "\e[0#{color_code}m#{text}\e[0m" : text
|
||||
end
|
||||
|
||||
def color_enabled?
|
||||
|
Loading…
Reference in New Issue
Block a user