Finish migrating ApiController error methods

This commit is contained in:
Justin Edmund 2022-12-21 23:28:54 -08:00
parent 415ef39158
commit c0be03dcb6
2 changed files with 8 additions and 3 deletions

View file

@ -10,6 +10,10 @@ module Api
field :errors, if: ->(_field_name, _error, options) { options.key?(:errors) } do |_, options| field :errors, if: ->(_field_name, _error, options) { options.key?(:errors) } do |_, options|
options[:errors] options[:errors]
end end
field :errors, if: ->(_field_name, _error, options) { options.key?(:exception) } do |_, options|
options[:exception]
end
end end
end end
end end

View file

@ -61,8 +61,8 @@ module Api
end end
def render_unprocessable_entity_response(exception) def render_unprocessable_entity_response(exception)
@exception = exception render json: ErrorBlueprint.render_as_json(nil, exception: exception),
render action: 'errors', status: :unprocessable_entity status: :unprocessable_entity
end end
def render_validation_error_response(object) def render_validation_error_response(object)
@ -78,7 +78,8 @@ module Api
end end
def render_unauthorized_response def render_unauthorized_response
render action: 'errors', status: :unauthorized render json: ErrorBlueprint.render_as_json(nil),
status: :unauthorized
end end
private private