mirror of
https://github.com/hakanensari/frankfurter.git
synced 2024-10-29 23:32:35 +01:00
Return error message in body
This commit is contained in:
parent
79de4bcfc3
commit
4b33029e22
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user