Module: Alula::Dcp::ErrorHandler
- Included in:
- Alula::DcpOperations::Delete::InstanceMethods, Alula::DcpOperations::DeleteStaged::InstanceMethods, Alula::DcpOperations::Save::InstanceMethods
- Defined in:
- lib/alula/dcp/error_handler.rb
Overview
DCP Error Handler
Instance Method Summary collapse
Instance Method Details
#handle_errors(response) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/alula/dcp/error_handler.rb', line 7 def handle_errors(response) case response.http_status when 300..399 # Should never see a 300-range response code raise Alula::UnknownError, "The Alula-Ruby gem encountered a response code of #{response.http_status}, that should not happen" when 500..599 # Server errors, malformed data, etc AlulaError.for_response(response) when 400..499 # Validation errors usually model_errors = Util.model_errors_from_dcp_response(response) return AlulaError.for_response(response) unless model_errors annotate_errors(model_errors) false else raise Alula::UnknownError, "Unknown HTTP response code, aborting. Code: #{response.http_status}" end end |