Class: RelicLink::Coh3::Faraday::Response::RaiseStatsError

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/relic_link/coh3/faraday/response/raise_stats_error.rb

Overview

Middleware to catch CoH3 API errors and raise them as exceptions.

Instance Method Summary collapse

Instance Method Details

#on_complete(env) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/relic_link/coh3/faraday/response/raise_stats_error.rb', line 9

def on_complete(env)
  return unless env.success?

  body = env.body
  return unless body

  return if body['result']['code'].zero?

  raise_relic_error!(body, env)
end