Exception: Phocoder::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/phocoder/errors.rb

Direct Known Subclasses

HTTPError

Instance Method Summary collapse

Constructor Details

#initialize(error_or_message) ⇒ Error

Returns a new instance of Error.



4
5
6
7
8
9
10
# File 'lib/phocoder/errors.rb', line 4

def initialize(error_or_message)
  if error_or_message.is_a?(Exception)
    @error = error_or_message
  else
    @message = error_or_message
  end
end

Instance Method Details

#backtraceObject



16
17
18
19
20
21
22
# File 'lib/phocoder/errors.rb', line 16

def backtrace
  if @error
    @error.backtrace
  else
    super
  end
end

#inspectObject



24
25
26
27
28
29
30
# File 'lib/phocoder/errors.rb', line 24

def inspect
  if @error
    "#{@error.inspect} (wrapped in a #{self.class})"
  else
    super
  end
end

#messageObject



12
13
14
# File 'lib/phocoder/errors.rb', line 12

def message
  @message || "#{@error.class} (wrapped in a #{self.class}) - #{@error.message}"
end

#to_sObject



32
33
34
35
36
37
38
# File 'lib/phocoder/errors.rb', line 32

def to_s
  if @error
    "#{@error.class} (wrapped in a #{self.class}) - #{@error}"
  else
    super
  end
end