module Bitstamp::Handler
Public Instance Methods
handle_body(raw_body)
click to toggle source
# File lib/bitstamp/handler.rb, line 5 def handle_body(raw_body) body = JSON.parse(raw_body) if body.kind_of?(Hash) if body.has_key?('error') raise ::Bitstamp::Exception::ServiceError.new(body.fetch('error')) elsif body.has_key?('status') && body.fetch('status') == 'error' raise ::Bitstamp::Exception::ServiceError.new(body.fetch('reason')) end end return body rescue JSON::ParserError raise ::Bitstamp::Exception::InvalidContent.new(raw_body) end