Sha256: 6f31f1913c2fe41114da0912266ffb4ca4de934f8832929d548e8564a0aa7bd5

Contents?: true

Size: 734 Bytes

Versions: 9

Compression:

Stored size: 734 Bytes

Contents

module FbGraph
  class Exception < StandardError
    attr_accessor :code, :type, :message
    def initialize(code, message, body = '')
      @code = code
      if body.blank?
        @message = message
      else
        response = JSON.parse(body).with_indifferent_access
        @message = response[:error][:message]
        @type = response[:error][:type]
      end
    end
  end

  class BadRequest < Exception
    def initialize(message, body = '')
      super 400, message, body
    end
  end

  class Unauthorized < Exception
    def initialize(message, body = '')
      super 401, message, body
    end
  end

  class NotFound < Exception
    def initialize(message, body = '')
      super 404, message, body
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
fb_graph-2.1.7 lib/fb_graph/exception.rb
fb_graph-2.1.6 lib/fb_graph/exception.rb
fb_graph-2.1.5 lib/fb_graph/exception.rb
fb_graph-2.1.4 lib/fb_graph/exception.rb
fb_graph-2.1.3 lib/fb_graph/exception.rb
fb_graph-2.1.2 lib/fb_graph/exception.rb
fb_graph-2.1.1 lib/fb_graph/exception.rb
fb_graph-2.1.0 lib/fb_graph/exception.rb
fb_graph-2.1.0.alpha lib/fb_graph/exception.rb