Sha256: 386b660b025dc573ab0b36c5fa1455f6285f24ea487f8fe7ec3f3f9576b64b3f

Contents?: true

Size: 626 Bytes

Versions: 4

Compression:

Stored size: 626 Bytes

Contents

module Mashery
  class Exception < ::Exception
    def self.create(options = {})
      case options['code']
      when 1000 then ValidationException.new(options['data'])
      when 1001 then DuplicateObjectException.new("#{options['message']} (JSON-RPC error #{options['code']})")
      else JsonRpcException.new("#{options['message']} (JSON-RPC error #{options['code']})")
      end
    end
  end

  class JsonRpcException < Exception
  end

  class DuplicateObjectException < Exception
  end

  class ValidationException < Exception
    attr_reader :errors
    def initialize(errs= {})
      @errors = errs
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mashery-0.1.0 lib/mashery/exceptions.rb
mashery-0.0.11 lib/mashery/exceptions.rb
mashery-0.0.10 lib/mashery/exceptions.rb
mashery-0.0.9 lib/mashery/exceptions.rb