Sha256: 04d19027e1ac9ac3081c11a62a015375c8b41ecc1b89dc9289d752d45cf33a88

Contents?: true

Size: 668 Bytes

Versions: 4

Compression:

Stored size: 668 Bytes

Contents

module Masheri
  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 HttpException < Exception
  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
masheri-0.3.1 lib/masheri/exceptions.rb
masheri-0.2.0 lib/masheri/exceptions.rb
masheri-0.1.1 lib/masheri/exceptions.rb
masheri-0.1.0 lib/masheri/exceptions.rb