lib/gorillib/exception/raisers.rb in gorillib-0.4.2 vs lib/gorillib/exception/raisers.rb in gorillib-0.5.0

- old
+ new

@@ -23,11 +23,11 @@ # adjust_cromulance(cromulator, level) # rescue StandardError => err ; err.polish("setting cromulance #{level} for #{cromulator}") rescue nil ; raise ; end # end # def polish(extra_info) - filename, _, method_name = self.class.caller_parts + filename, _, method_name = self.class.caller_parts(2) method_name.gsub!(/rescue in /, '') most_recent_line = backtrace.detect{|line| line.include?(filename) && line.include?(method_name) && line.end_with?("'") } most_recent_line.sub!(/'$/, "' for [#{extra_info.to_s[0..300]}]") end @@ -98,9 +98,14 @@ message << ': ' << msg if msg unless types.empty? message << '; expected ' << types.map{|type| type.is_a?(Symbol) ? "##{type}" : type.to_s }.join(" or ") end raise self, message, *args + end + + + def self.block_required!(block) + raise self.new("Block is required") unless block end # # @param obj [Object] Object to check # @param types [Array[Symbol,Class,Module]] Types or methods to compare