class HealthBit::CheckError

Constants

FORMAT_FULL
FORMAT_SHORT

Attributes

exception[R]
name[R]

Public Class Methods

new(name, exception: nil) click to toggle source
# File lib/health_bit/check_error.rb, line 10
def initialize(name, exception: nil)
  @name = name
  @exception = exception
end

Public Instance Methods

to_s(format = nil) click to toggle source

@return [String]

# File lib/health_bit/check_error.rb, line 16
def to_s(format = nil)
  io = StringIO.new
  io.puts "Check <#{name}> failed"

  case format
  when FORMAT_FULL
    describe_exception(io)
  end

  io.string.chomp
end

Private Instance Methods

describe_exception(io) click to toggle source
# File lib/health_bit/check_error.rb, line 30
def describe_exception(io)
  return if exception.nil?

  io.puts exception.inspect
  io.puts Array(exception.backtrace).join("\n")
end