Sha256: 7d4452afe28e1925b6066dee2c61fb5884e7155e398b6cc6d770722f4d955db6

Contents?: true

Size: 597 Bytes

Versions: 2

Compression:

Stored size: 597 Bytes

Contents

require 'faraday'

module Faraday
  class Response::RaiseMtGoxError < Response::Middleware
    def on_complete(env)
      if 200 == env[:status] && 'MySQL error, please retry later' == env[:body]
        raise MtGox::MysqlError, "MySQL error, please retry later"
      elsif 403 == env[:status] && MultiJson.load(env[:body])["result"] == "error"
        raise MtGox::UnauthorizedError, MultiJson.load(env[:body])["error"]
      elsif 404 != env[:status] && MultiJson.load(env[:body])["result"] == "error"
        raise MtGox::Error, MultiJson.load(env[:body])["error"]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mtgox-0.9.1 lib/faraday/response/raise_mtgox_error.rb
mtgox-0.9.0 lib/faraday/response/raise_mtgox_error.rb