Exception: Xio::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/xio/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/xio/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
23
24
# File 'lib/xio/errors.rb', line 16

def backtrace
  if @error
    error_backtrace = ["--- Backtrace from #{@error.class} ---"] + (@error.backtrace || [])
    wrapper_backtrace = ["--- Backtrace from #{self.class} ---"] + (super || [])
    error_backtrace + wrapper_backtrace
  else
    super
  end
end

#inspectObject



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

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

#messageObject



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

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

#to_sObject



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

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