Return error message in body

This commit is contained in:
Hakan Ensari 2022-03-07 12:02:12 +00:00
parent 79de4bcfc3
commit 4b33029e22

View File

@ -21,8 +21,9 @@ module Web
plugin :caching plugin :caching
plugin :error_handler do |_error| plugin :halt
request.halt [422, {}, nil] plugin :error_handler do |error|
request.halt 422, { message: error.message }
end end
plugin :indifferent_params plugin :indifferent_params
@ -76,7 +77,7 @@ module Web
query = Query.build(request.params) query = Query.build(request.params)
quote = Quote::EndOfDay.new(**query) quote = Quote::EndOfDay.new(**query)
quote.perform quote.perform
request.halt [404, {}, nil] if quote.not_found? request.halt 404, { message: 'not found' } if quote.not_found?
quote quote
end end
@ -85,7 +86,7 @@ module Web
query = Query.build(request.params) query = Query.build(request.params)
quote = Quote::Interval.new(**query) quote = Quote::Interval.new(**query)
quote.perform quote.perform
request.halt [404, {}, nil] if quote.not_found? request.halt 404, { message: 'not found' } if quote.not_found?
quote quote
end end