class ErrorHandlingIface
Provides a base class that provides all the methods required for custom error handling
Public Instance Methods
failValidation(trace=caller(1))
click to toggle source
Wrapper method to raise an INSX_ArgumentError with proper parameters @example Validate a parameter
failValidation if not (param == value)
# File lib/insxsync/error_handling_iface.rb, line 8 def failValidation(trace=caller(1)) raise InsxArgumentError.new(get_usage, self.class.name, trace) end
get_usage()
click to toggle source
Provides the parent method for returning the usage of the calling method. This method should be overridden in every subclass to setup a usage hash using the method names as the keys and an array of strings as the values. @example Example get_usage
child method
def get_usage if @usage.nil? init_usage @usage['new'] = [':paramA => String, :paramB=> String'] end super end
# File lib/insxsync/error_handling_iface.rb, line 24 def get_usage #if called from the initialize method, the user should see "new" sender = caller[2][/`([^']+)'/,1] == 'initialize' ? 'new' : caller[2][/`([^']+)'/,1] #search through each method in the hash and load it's usage(s) @usage.each_key do |method| if method == sender return @usage[method] end end @usage[nil] end
init_usage()
click to toggle source
Initializes the usage hash for a instance such that any entries that do not exist return '*** WARNING: Usage not defined ***' as the message
# File lib/insxsync/error_handling_iface.rb, line 40 def init_usage @usage = Hash.new(['*** WARNING: Usage not defined ***']) end