Sha256: b2f9bd736029183da15f04e53aeea802663fbf77c6215f59eba1dfb43abbce28

Contents?: true

Size: 665 Bytes

Versions: 15

Compression:

Stored size: 665 Bytes

Contents

module Muddyit
  
    class Error < RuntimeError
      attr_accessor :code
    end

    class Errors
      # Method used for raising the appropriate error class for a given error code.
      # Currently raises only Muddyit::Error
      def self.error_for(code, message)
        raise RuntimeError.new("Internal error. Muddyit API error not identified or unknown error.") if (code.nil? || message.nil? || message.empty?)
        raise RuntimeError.new("Internal error. Unknown error.") if code.to_i == 0 # We assume that error code 0 is never returned
        e = Muddyit::Error.new("#{code}: #{message}")
        e.code = code
        raise e
      end
    end

end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
monkeyhelper-muddyit_fu-0.1.0 lib/muddyit/errors.rb
monkeyhelper-muddyit_fu-0.1.1 lib/muddyit/errors.rb
monkeyhelper-muddyit_fu-0.2.0 lib/muddyit/errors.rb
monkeyhelper-muddyit_fu-0.2.1 lib/muddyit/errors.rb
monkeyhelper-muddyit_fu-0.2.2 lib/muddyit/errors.rb
monkeyhelper-muddyit_fu-0.2.3 lib/muddyit/errors.rb
monkeyhelper-muddyit_fu-0.2.4 lib/muddyit/errors.rb
muddyit_fu-0.2.14 lib/muddyit/errors.rb
muddyit_fu-0.2.13 lib/muddyit/errors.rb
muddyit_fu-0.2.12 lib/muddyit/errors.rb
muddyit_fu-0.2.11 lib/muddyit/errors.rb
muddyit_fu-0.2.10 lib/muddyit/errors.rb
muddyit_fu-0.2.9 lib/muddyit/errors.rb
muddyit_fu-0.2.8 lib/muddyit/errors.rb
muddyit_fu-0.2.6 lib/muddyit/errors.rb