class ZError

Attributes

error_code[RW]
help_func[RW]
message[RW]
retry[RW]

Public Class Methods

new(message=nil, params={}) click to toggle source

list of valid params :help_func, the help function with more information for the exception : retry, is the exception eligible for retry?

Calls superclass method
# File zbxapi/exceptions.rb, line 43
def initialize(message=nil, params={})
  @help_func=params[:help_func]
  @message=message
  @local_msg="Error"
  @retry = params[:retry]
  @error_code= params[:error_code]
  super(message)
end

Public Instance Methods

retry?() click to toggle source
# File zbxapi/exceptions.rb, line 76
def retry?
  #the following may be worthy of a sig on "The Daily WTF", but this guarantees a boolean gets returned.
  #@retry is not guaranteed to be a boolean.
  if @retry
    return true
  else
    return false
  end
end
show_backtrace(override=false) click to toggle source

show the backtrace, if override is true it will be shown even if there is a help function

# File zbxapi/exceptions.rb, line 70
def show_backtrace(override=false)
  if @help_func.nil? || override
    puts "Backtrace:"
    puts backtrace.join("\n")
  end
end
show_message() click to toggle source
# File zbxapi/exceptions.rb, line 52
def show_message
  puts "** #{self.class}"
  if @message.nil? && @help_func.nil?
    puts "** #{@local_msg}"
    puts
  else
    if !@message.nil?
      @message.each_line {|line|
        puts "** #{line}"
      }
      puts
      puts "---" if !@help_func.nil?
    end
    @help_func.call if !@help_func.nil?
  end
end