Class: MobyBase::Error
Constant Summary collapse
- @@errors =
{ :WrongArgumentType => {:type => "ArgumentError", :text => "Wrong argument type %s (Expected %s)"}, :WrongArgumentTypeFor => {:type => "ArgumentError", :text => "Wrong argument type %s for %s (Expected %s)"}, :ArgumentSymbolExpected => {:type => "ArgumentError", :text => "Symbol %s expected in argument(s)"}, :InvalidStringLengthFor => {:type => "ArgumentError", :text => "Invalid string length (%i) for %s (Expected %s)"}, :BehaviourErrorOccured => {:type => "RuntimeError", :text => "%s method failed with message: %s. Debug info: %s"} }
Class Method Summary collapse
Class Method Details
.raise(error_id, *params) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/tdriver/base/errors.rb', line 33 def self.raise( error_id, *params ) if @@errors.has_key?( error_id ) error_type = eval(@@errors[ error_id ][ :type ]) error_text = @@errors[ error_id ][ :text ] # Replace %s to given parameters = error_text.gsub( /\%[-]*\d*[disxX]/ ) { | match | ( params.size > 0 ) ? "#{ match }" % params.shift : match } else # Raise ArgumentError if given id is not defined in @@error_base hash table error_type = ArgumentError = "No error found for ID '%s' (Parameters: %s)" % [ error_id, params.join( ", " ) ] end error = error_type.new( ) raise error end |