Exception: Collavre::ApiError

Inherits:
StandardError
  • Object
show all
Defined in:
app/errors/collavre/api_error.rb

Overview

Raised inside collavre-core API v1 controllers to produce the canonical single-message JSON envelope { error: "<message>" } at a chosen status, via the rescue_from in Collavre::Api::V1::BaseController.

NOTE: this is the collavre-core {error: "str"} shape only. It is NOT for the 422 validation-array shape {errors: [...]} (client retry contract), nor the OpenAI-nested shape in collavre_completion_api. Do not route those through this class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, status: :unprocessable_entity) ⇒ ApiError

Returns a new instance of ApiError.



15
16
17
18
# File 'app/errors/collavre/api_error.rb', line 15

def initialize(message, status: :unprocessable_entity)
  super(message)
  @status = status
end

Instance Attribute Details

#statusObject (readonly)

Returns the value of attribute status.



13
14
15
# File 'app/errors/collavre/api_error.rb', line 13

def status
  @status
end