Skip to content

@retoo /log_1.6_error.rb secret
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
# original log_error method
def self.log_single_error(exception)
message = "\n#{exception.class} (#{exception.message}):\n"
message << exception.annoted_source_code.to_s if exception.respond_to?(:annoted_source_code)
message << " " << exception.backtrace.join("\n ")
$stderr.puts("#{message}\n\n")
end
def self.log_and_exit_if_error
begin
yield
rescue => e
print_error(e)
exit 1
end
end
def self.print_error(exception)
steps = 30
while true
log_single_error(exception)
# use begin/rescue block as respond_to is not relaible
begin
break if exception == exception.cause
exception = exception.cause
rescue
# no cause field
break
end
break unless exception
break if steps < 0
steps -= 1
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.