From 2e5e55444ce74b0d5b08739ce62f1daf7efd3a30 Mon Sep 17 00:00:00 2001 From: Mwaki Harri Magotswi Date: Wed, 14 Jan 2026 18:46:19 -0500 Subject: [PATCH 1/2] adding a redirect error with info --- lib/dothoop.rb | 1 + lib/dothoop/error_handling_resourcable.rb | 4 ++++ test/lib/dothoop_test.rb | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/lib/dothoop.rb b/lib/dothoop.rb index 855ada5..90fda5f 100644 --- a/lib/dothoop.rb +++ b/lib/dothoop.rb @@ -70,4 +70,5 @@ module Dothoop NotFoundError = Class.new(Dothoop::Error) UnprocessableEntityError = Class.new(Dothoop::Error) TooManyRequestsError = Class.new(Dothoop::Error) + RedirectError = Class.new(Dothoop::Error) end diff --git a/lib/dothoop/error_handling_resourcable.rb b/lib/dothoop/error_handling_resourcable.rb index 11f8768..4079115 100644 --- a/lib/dothoop/error_handling_resourcable.rb +++ b/lib/dothoop/error_handling_resourcable.rb @@ -1,9 +1,13 @@ +require 'pry' + module ErrorHandlingResourcable def self.included(base) base.send(:resources) do default_handler do |response| if (200...299).include?(response.status) next + elsif response.status == 301 + raise Dothoop::RedirectError.new({status: response.status, body: response.body, redirect: response.headers[:location]}) elsif response.status == 401 raise Dothoop::UnauthorizedError.new("#{response.status}: #{response.body}") elsif response.status == 403 diff --git a/test/lib/dothoop_test.rb b/test/lib/dothoop_test.rb index e4f39a1..0e699aa 100644 --- a/test/lib/dothoop_test.rb +++ b/test/lib/dothoop_test.rb @@ -30,4 +30,8 @@ def test_too_many_requests_error_is_initialized assert Dothoop::TooManyRequestsError end + def test_redirect_error_is_initialized + assert Dothoop::RedirectError + end + end From 5247d1c5ca624d555a1758cd6b84d11fa2e8323a Mon Sep 17 00:00:00 2001 From: Mwaki Harri Magotswi Date: Thu, 15 Jan 2026 13:11:56 -0500 Subject: [PATCH 2/2] removing some debugging code and bumping the gem version to 0.1.7 --- lib/dothoop/error_handling_resourcable.rb | 2 -- lib/dothoop/version.rb | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/dothoop/error_handling_resourcable.rb b/lib/dothoop/error_handling_resourcable.rb index 4079115..a824bd4 100644 --- a/lib/dothoop/error_handling_resourcable.rb +++ b/lib/dothoop/error_handling_resourcable.rb @@ -1,5 +1,3 @@ -require 'pry' - module ErrorHandlingResourcable def self.included(base) base.send(:resources) do diff --git a/lib/dothoop/version.rb b/lib/dothoop/version.rb index 27b5c35..dc52a37 100644 --- a/lib/dothoop/version.rb +++ b/lib/dothoop/version.rb @@ -1,3 +1,3 @@ module Dothoop - VERSION = "0.1.6" + VERSION = "0.1.7" end