Exception: Pixmatch::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/pixmatch/error.rb

Overview

Custom error class for rescuing from all known Pixmatch errors.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ Error

Returns a new instance of Error.



6
7
8
9
10
11
# File 'lib/pixmatch/error.rb', line 6

def initialize(json)
  @status = json['status']
  @method = json['method']
  @error = json['error']
  @result = json['result']
end

Instance Attribute Details

#detailObject

Returns the value of attribute detail.



4
5
6
# File 'lib/pixmatch/error.rb', line 4

def detail
  @detail
end

#methodObject

Returns the value of attribute method.



4
5
6
# File 'lib/pixmatch/error.rb', line 4

def method
  @method
end

#statusObject

Returns the value of attribute status.



4
5
6
# File 'lib/pixmatch/error.rb', line 4

def status
  @status
end

Instance Method Details

#to_sObject



13
14
15
16
# File 'lib/pixmatch/error.rb', line 13

def to_s
  s = @error.nil? ? 'Unexpected Error' : @error.join('\r\n')
  s += ("\r\n " + @result.join('\r\n ')) if @result
end