lib/stash/server.rb in face_control-0.8.6 vs lib/stash/server.rb in face_control-0.9.0
- old
+ new
@@ -1,12 +1,10 @@
require 'httparty'
require 'stash/repository'
module Stash
class Server
- class CommunicationError < StandardError; end
-
attr_accessor :root_uri, :user, :password, :logger
def initialize(root_uri, user, password, logger = nil)
self.root_uri = root_uri
self.user = user
@@ -19,22 +17,18 @@
@repositories ||= {}
@repositories[key] ||= Repository.new(self, project_key, repository_slug)
end
def get(path)
- with_error_handling do
- logged('Response') do
- HTTParty.get(endpoint + path, auth.merge(logging))
- end
+ logged('Response') do
+ HTTParty.get(endpoint + path, auth.merge(logging))
end
end
def post(path, data)
- with_error_handling do
- logged('Response') do
- HTTParty.post(endpoint + path, auth.merge(content_type).merge(body: data.to_json).merge(logging))
- end
+ logged('Response') do
+ HTTParty.post(endpoint + path, auth.merge(content_type).merge(body: data.to_json).merge(logging))
end
end
private
@@ -75,17 +69,9 @@
logger: logger,
log_level: :debug
}
else
{}
- end
- end
-
- def with_error_handling
- yield.tap do |response|
- unless response.success?
- fail CommunicationError, 'Stash responded with an error'
- end
end
end
end
end