class WarpEngine::AdminApi::Error
An Admin API failure with the HTTP status it answers with. The controller and Mcp render it as { error:, details: } (see body) with headers set.
Attributes
The HTTP status code, the optional details hash (field name to messages) and the extra response headers.
The HTTP status code, the optional details hash (field name to messages) and the extra response headers.
The HTTP status code, the optional details hash (field name to messages) and the extra response headers.
Public Class Methods
Source
# File lib/warp_engine/admin_api/error.rb, line 17 def self.bad_request(message) = new(400, message)
A 400 with message.
Source
# File lib/warp_engine/admin_api/error.rb, line 19 def self.conflict(message) = new(409, message)
A 409 with message.
# File lib/warp_engine/admin_api/error.rb, line 15 def self.forbidden(message = "Forbidden") = new(403, message)
A 403 with message.
Source
# File lib/warp_engine/admin_api/error.rb, line 25 def self.invalid(record) details = record.errors.to_hash.transform_keys { |key| key.to_s.camelize(:lower) } new(422, "Validation failed", details: details) end
A 422 Validation failed whose details are the validation errors of record, keyed by lower camel case attribute names.
# File lib/warp_engine/admin_api/error.rb, line 34 def initialize(status, message, details: nil, headers: {}) super(message) @status = status @details = details @headers = headers end
- status
-
the HTTP status code
- message
-
the error message
- details
-
an optional hash of further details
- headers
-
extra response headers
Source
# File lib/warp_engine/admin_api/error.rb, line 11 def self.not_found = new(404, "Not found")
A 404 Not found.
Source
# File lib/warp_engine/admin_api/error.rb, line 21 def self.read_only = new(405, "The Admin API is read-only here")
A 405 for a write on a read-only Admin API (Configuration#read_only).
Public Instance Methods
Source
# File lib/warp_engine/admin_api/error.rb, line 42 def body { error: message, details: details }.compact end
The JSON body of the error: { error:, details: } without a nil details.