lib/fizzy/api/calculate_outcome.rb in fizzy-api-0.0.5 vs lib/fizzy/api/calculate_outcome.rb in fizzy-api-0.0.6

- old
+ new

@@ -15,13 +15,20 @@ def process_response(response) case response.code when 200 response + else + invalid_response(response) + end + end + + def invalid_response(response) + case response.code when 202 - raise Errors::OutcomeNotAvailableError, 'The results are currently being calculated.' + raise Errors::OutcomeNotAvailableError, response.body || 'The results are currently being calculated.' when 404 - raise Errors::GraphNotFoundError, 'Participant not found, or graph not supported.' + raise Errors::GraphNotFoundError, response.body || 'Participant not found, or graph not supported.' else raise Errors::UnexpectedStatusError, "Status code #{response.code} not expected." end end end