Sha256: a8a9b9430071cc1434f1927fc7e143e8b193f66ab9b74015d8d0276d2936358a
Contents?: true
Size: 702 Bytes
Versions: 1
Compression:
Stored size: 702 Bytes
Contents
module ReversePolishCalculator module Errors MethodMapping = { NoMethodError => :no_method_error, Math::DomainError => :math_domain_error } Classes = MethodMapping.keys def self.handle(exception) send(MethodMapping[exception.class], exception) end def self.no_method_error(exception) ReversePolishCalculator.stack.remove(exception.name) Helpers.multi_puts "Cannot calculate '#{exception.name}'" end def self.math_domain_error(exception) name = exception.message.match(/"(.+)"/)[1] ReversePolishCalculator.stack.remove(name) Helpers.multi_puts "Bad value for '#{name}'" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
reverse-polish-calculator-0.0.1 | lib/reverse-polish-calculator/errors.rb |