lib/flexmls_api/faraday.rb in flexmls_api-0.7.0 vs lib/flexmls_api/faraday.rb in flexmls_api-0.7.3

- old
+ new

@@ -22,22 +22,31 @@ else results = paginate_response(response, paging) end end case finished_env[:status] - when 400, 409 - raise BadResourceRequest, {:message => response.message, :code => response.code, :status => finished_env[:status]} + when 400 + hash = {:message => response.message, :code => response.code, :status => finished_env[:status]} + + # constraint violation + if response.code == 1053 + details = body['D']['Details'] + hash[:details] = details + end + raise BadResourceRequest,hash when 401 # Handle the WWW-Authenticate Response Header Field if present. This can be returned by # OAuth2 implementations and wouldn't hurt to log. auth_header_error = finished_env[:request_headers]["WWW-Authenticate"] FlexmlsApi.logger.warn("Authentication error #{auth_header_error}") unless auth_header_error.nil? raise PermissionDenied, {:message => response.message, :code => response.code, :status => finished_env[:status]} when 404 raise NotFound, {:message => response.message, :code => response.code, :status => finished_env[:status]} when 405 - raise NotAllowed, {:message => response.message, :code => response.code, :status => finished_env[:status]} + raise NotAllowed, {:message => response.message, :code => response.code, :status => finished_env[:status]} + when 409 + raise BadResourceRequest, {:message => response.message, :code => response.code, :status => finished_env[:status]} when 500 raise ClientError, {:message => response.message, :code => response.code, :status => finished_env[:status]} when 200..299 FlexmlsApi.logger.debug("Success!") else @@ -49,8 +58,7 @@ def initialize(app) super(app) end end - end end