ministryofjustice/Claim-for-Crown-Court-Defence

View on GitHub
app/interfaces/api/helpers/error_logging_helper.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
module API
  module Helpers
    module ErrorLoggingHelper
      def log_error(status, error)
        LogStuff.send(
          :error,
          type: 'api-error',
          request_id: env['action_dispatch.request_id'],
          error: error ? "#{error.class} - #{error.message}" : 'false',
          status:
        ) do
          "API request failed with code #{status}"
        end
      end
    end
  end
end