From ec4109d413f6161b43ad4cc1a6251af30d3bcf03 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Thu, 12 Jul 2018 23:17:05 -0700 Subject: Make Connection#post consistent with Connection#get and add specs --- lib/bitbucket_server/connection.rb | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'lib/bitbucket_server') diff --git a/lib/bitbucket_server/connection.rb b/lib/bitbucket_server/connection.rb index 0e7817fc82e..853d09b776a 100644 --- a/lib/bitbucket_server/connection.rb +++ b/lib/bitbucket_server/connection.rb @@ -33,22 +33,22 @@ module BitbucketServer check_errors!(response) - response + response.parsed_response end private def check_errors!(response) - if response.code != 200 - error = - if response.parsed_response && response.parsed_response.is_a?(Hash) - sanitize(response.parsed_response.dig('errors', 0, 'message')) - end - - message = "Error #{response.code}" - message += ": #{error}" if error - raise ConnectionError, message - end + return if response.code == 200 + + details = + if response.parsed_response && response.parsed_response.is_a?(Hash) + sanitize(response.parsed_response.dig('errors', 0, 'message')) + end + + message = "Error #{response.code}" + message += ": #{details}" if details + raise ConnectionError, message end def auth -- cgit v1.2.3