From 30c7975fbcc6dac2f2556b7d4882a6090196b837 Mon Sep 17 00:00:00 2001 From: Burkhard Vogel-Kreykenbohm Date: Fri, 11 Aug 2023 17:42:14 +0200 Subject: [PATCH 1/2] Adding args to error to gain more insight on failing requests --- lib/noticed.rb | 4 +++- lib/noticed/delivery_methods/base.rb | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/noticed.rb b/lib/noticed.rb index 921598eb..3ba562dd 100644 --- a/lib/noticed.rb +++ b/lib/noticed.rb @@ -33,9 +33,11 @@ class ValidationError < StandardError class ResponseUnsuccessful < StandardError attr_reader :response + attr_reader :args - def initialize(response) + def initialize(response, args = {}) @response = response + @args = args end end end diff --git a/lib/noticed/delivery_methods/base.rb b/lib/noticed/delivery_methods/base.rb index 3b6793c0..04ce65c5 100644 --- a/lib/noticed/delivery_methods/base.rb +++ b/lib/noticed/delivery_methods/base.rb @@ -85,7 +85,7 @@ def post(url, args = {}) if !options[:ignore_failure] && !response.status.success? puts response.status puts response.body - raise ResponseUnsuccessful.new(response) + raise ResponseUnsuccessful.new(response, args) end response From 7af3e63f4d770eab4655fc3e4c08b8a3a9f31cc2 Mon Sep 17 00:00:00 2001 From: Burkhard Vogel-Kreykenbohm Date: Fri, 11 Aug 2023 17:46:50 +0200 Subject: [PATCH 2/2] remove puts to clean up logs --- lib/noticed/delivery_methods/base.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/noticed/delivery_methods/base.rb b/lib/noticed/delivery_methods/base.rb index 04ce65c5..8056fd17 100644 --- a/lib/noticed/delivery_methods/base.rb +++ b/lib/noticed/delivery_methods/base.rb @@ -83,8 +83,8 @@ def post(url, args = {}) end if !options[:ignore_failure] && !response.status.success? - puts response.status - puts response.body + logger.warn("failed POST status: #{response.status}") + logger.warn("failed POST response body: #{response.body}") raise ResponseUnsuccessful.new(response, args) end