Exception: AppleBot::AppleBotError
- Inherits:
-
StandardError
- Object
- StandardError
- AppleBot::AppleBotError
- Defined in:
- lib/applebot/error.rb,
lib/applebot/error.rb
Direct Known Subclasses
AppIdNotFound, AppNameTakenError, AppleMaintenanceMode, AuthenticationError, MultipleProfileError
Instance Attribute Summary collapse
-
#html ⇒ Object
readonly
Returns the value of attribute html.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(error, output = [], message = nil) ⇒ AppleBotError
constructor
A new instance of AppleBotError.
- #is_debug_html?(line) ⇒ Boolean
Constructor Details
#initialize(error, output = [], message = nil) ⇒ AppleBotError
Returns a new instance of AppleBotError.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/applebot/error.rb', line 7 def initialize(error, output = [], = nil) super(self.class.) 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 |
Instance Attribute Details
#html ⇒ Object (readonly)
Returns the value of attribute html.
5 6 7 |
# File 'lib/applebot/error.rb', line 5 def html @html end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
5 6 7 |
# File 'lib/applebot/error.rb', line 5 def output @output end |
Class Method Details
.for_output(output = []) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/applebot/error.rb', line 68 def self.for_output(output = []) output ||= [] error_class = nil output.each { |line| MESSAGE_FRAGMENT_TO_ERROR.each { |, klass| if line.include?() 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 |
.test ⇒ Object
92 93 94 |
# File 'lib/applebot/error.rb', line 92 def self.test raise for_output(["something", "happened"]) end |
Instance Method Details
#is_debug_html?(line) ⇒ Boolean
27 28 29 |
# File 'lib/applebot/error.rb', line 27 def is_debug_html?(line) line.include?('"event":"debug_html"') end |