Exception: VirusScanner::Error

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

Direct Known Subclasses

HTTPError

Instance Method Summary collapse

Constructor Details

#initialize(statement) ⇒ Error

Returns a new instance of Error.



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

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

Instance Method Details

#backtraceObject



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

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



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

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

#messageObject



11
12
13
# File 'lib/virus_scanner/errors.rb', line 11

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

#to_sObject



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

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