Exception: ActsAsPhocodable::Error

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

Instance Method Summary collapse

Constructor Details

#initialize(error_or_message) ⇒ Error

Returns a new instance of Error.



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

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



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

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

#inspectObject



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

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

#messageObject



13
14
15
# File 'lib/phocoder_rails/errors.rb', line 13

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

#to_sObject



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

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