From 5d5a18a880c9d60e2152e061a7a9bfec16fe5615 Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Wed, 5 Aug 2020 10:03:46 +1000 Subject: [PATCH] feat: print out helpful error message for 403 --- lib/pact_broker/client/base_client.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/pact_broker/client/base_client.rb b/lib/pact_broker/client/base_client.rb index 2df7b8e7..6369f7c7 100644 --- a/lib/pact_broker/client/base_client.rb +++ b/lib/pact_broker/client/base_client.rb @@ -69,6 +69,12 @@ def handle_response response yield response elsif response.code == 404 nil + elsif response.code == 403 + message = "Authorization failed (insufficient permissions)" + if response.body && response.body.size > 0 + message = message + ": #{response.body}" + end + raise Error.new(message) elsif response.code == 401 message = "Authentication failed" if response.body && response.body.size > 0