Class: BatchApi::Errors::Request

Inherits:
Base
  • Object
show all
Defined in:
lib/batch_api/errors/request.rb

Overview

Public: This class encapsulates errors that occur at a request level. For instance, it returns proper error codes for BadOptionErrors or other identifiable problems. (For actual code errors, it returns a 500 response.)

Instance Method Summary collapse

Methods inherited from Base

#body, expose_backtrace?, #initialize, #render

Constructor Details

This class inherits a constructor from BatchApi::Errors::Base

Instance Method Details

#status_codeObject

Public: return the appropriate status code for the error. For errors from bad Batch API input, raise a 422, otherwise, a 500.



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/batch_api/errors/request.rb', line 12

def status_code
  case @error
  when BatchApi::Processor::BadOptionError,
       BatchApi::Processor::OperationLimitExceeded,
       BatchApi::Processor::NoOperationsError,
       BatchApi::Operation::MalformedOperationError
    422
  else
    500
  end
end