class AppleBot::AppleBotError
Attributes
html[R]
output[R]
Public Class Methods
for_output(output = [])
click to toggle source
# File lib/applebot/error.rb, line 68 def self.for_output(output = []) output ||= [] error_class = nil output.each { |line| MESSAGE_FRAGMENT_TO_ERROR.each { |message, klass| if line.include?(message) error_class = klass break end } break if error_class } error_class ||= AppleBotError begin # capture the Ruby-level stack trace raise StandardError rescue Exception => e error_class.new(e, output) end end
new(error, output = [], message = nil)
click to toggle source
Calls superclass method
# File lib/applebot/error.rb, line 7 def initialize(error, output = [], message = nil) super(self.class.message) output ||= [] output = output.map(&:strip).reject(&:blank?) @html = output.select {|n| is_debug_html?(n) }.map { |s| JSON.parse(s)['html'] }.first @output = output.reject {|n| is_debug_html?(n) } full_backtrace = (@output.map { |o| "#{o}:in `AppleBot'" } + error.backtrace).compact set_backtrace(full_backtrace) end
test()
click to toggle source
# File lib/applebot/error.rb, line 92 def self.test raise for_output(["something", "happened"]) end
Public Instance Methods
is_debug_html?(line)
click to toggle source
# File lib/applebot/error.rb, line 27 def is_debug_html?(line) line.include?('"event":"debug_html"') end