Finish migrating ApiController error methods
This commit is contained in:
parent
415ef39158
commit
c0be03dcb6
2 changed files with 8 additions and 3 deletions
|
|
@ -10,6 +10,10 @@ module Api
|
|||
field :errors, if: ->(_field_name, _error, options) { options.key?(:errors) } do |_, options|
|
||||
options[:errors]
|
||||
end
|
||||
|
||||
field :errors, if: ->(_field_name, _error, options) { options.key?(:exception) } do |_, options|
|
||||
options[:exception]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -61,8 +61,8 @@ module Api
|
|||
end
|
||||
|
||||
def render_unprocessable_entity_response(exception)
|
||||
@exception = exception
|
||||
render action: 'errors', status: :unprocessable_entity
|
||||
render json: ErrorBlueprint.render_as_json(nil, exception: exception),
|
||||
status: :unprocessable_entity
|
||||
end
|
||||
|
||||
def render_validation_error_response(object)
|
||||
|
|
@ -78,7 +78,8 @@ module Api
|
|||
end
|
||||
|
||||
def render_unauthorized_response
|
||||
render action: 'errors', status: :unauthorized
|
||||
render json: ErrorBlueprint.render_as_json(nil),
|
||||
status: :unauthorized
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
|||
Loading…
Reference in a new issue