Browse Source

Change error code

CLDC-3787-Autocomplete-address-search
Manny Dinssa 1 week ago
parent
commit
df5e791b5f
  1. 6
      app/controllers/address_search_controller.rb

6
app/controllers/address_search_controller.rb

@ -11,7 +11,7 @@ class AddressSearchController < ApplicationController
service.call service.call
if service.error.present? if service.error.present?
render json: { error: service.error }, status: :unprocessable_entity render json: { error: service.error }, status: :not_found
else else
presenter = UprnDataPresenter.new(service.result) presenter = UprnDataPresenter.new(service.result)
render json: [{ text: presenter.address, value: presenter.uprn }] render json: [{ text: presenter.address, value: presenter.uprn }]
@ -22,7 +22,7 @@ class AddressSearchController < ApplicationController
service.call service.call
if service.error.present? if service.error.present?
render json: { error: service.error }, status: :unprocessable_entity render json: { error: service.error }, status: :not_found
else else
results = service.result.map do |result| results = service.result.map do |result|
presenter = AddressDataPresenter.new(result) presenter = AddressDataPresenter.new(result)
@ -41,7 +41,7 @@ class AddressSearchController < ApplicationController
results = (address_service.result || []) + (uprn_service.result || []) results = (address_service.result || []) + (uprn_service.result || [])
if address_service.error.present? && uprn_service.error.present? if address_service.error.present? && uprn_service.error.present?
render json: { error: "Address and UPRN are not recognised." }, status: :unprocessable_entity render json: { error: "Address and UPRN are not recognised." }, status: :not_found
else else
formatted_results = results.map do |result| formatted_results = results.map do |result|
presenter = AddressDataPresenter.new(result) presenter = AddressDataPresenter.new(result)

Loading…
Cancel
Save