Class: Rx::Middleware::Response::RxFailedStation

Inherits:
Faraday::Middleware
  • Object
show all
Includes:
SentryLogging
Defined in:
lib/rx/middleware/response/rx_failed_station.rb

Overview

Middleware class responsible for logging Rx Failed Station messages to Sentry

Instance Method Summary collapse

Methods included from SentryLogging

#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger, #set_sentry_metadata

Instance Method Details

#on_complete(env) ⇒ Faraday::Env

Override the Faraday #on_complete method to log Rx failed station message to Sentry

Parameters:

  • env (Faraday::Env)

    the request environment

Returns:

  • (Faraday::Env)


16
17
18
19
20
21
22
23
24
# File 'lib/rx/middleware/response/rx_failed_station.rb', line 16

def on_complete(env)
  return unless env.body.is_a? Hash

  station_list = env.body.try(:[], :metadata).try(:[], :failed_station_list)
  return if station_list.blank?

  message = "Warning: prescription failed station list is not empty, '#{station_list}'"
  log_message_to_sentry(message, :warn)
end