From a676fe2941464f42d2877f3d45d0403d95b048f1 Mon Sep 17 00:00:00 2001 From: Renato Cron Date: Fri, 15 Dec 2023 16:03:47 +0000 Subject: [PATCH] Ignorar erros (throws) a cada find, para que todos os backends sejam testados --- api/lib/Penhas/Controller/SignUp.pm | 4 +++- api/lib/Penhas/Minion/Tasks/CepUpdater.pm | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/api/lib/Penhas/Controller/SignUp.pm b/api/lib/Penhas/Controller/SignUp.pm index f0afc17..9a6c9ce 100644 --- a/api/lib/Penhas/Controller/SignUp.pm +++ b/api/lib/Penhas/Controller/SignUp.pm @@ -83,7 +83,9 @@ sub post { eval { foreach my $backend (map { Penhas::CEP->new_with_traits(traits => $_) } qw(ViaCep Correios)) { my @_address_fields = qw(city state); - $result = $backend->find($cep); + $result = eval{$backend->find($cep)}; + $c->log->error("Error during cep find using $backend: $@") if ($@); + if ($result) { # para o teste dos backend se todos os campos estão preenchidos diff --git a/api/lib/Penhas/Minion/Tasks/CepUpdater.pm b/api/lib/Penhas/Minion/Tasks/CepUpdater.pm index 68213f5..938f7e5 100644 --- a/api/lib/Penhas/Minion/Tasks/CepUpdater.pm +++ b/api/lib/Penhas/Minion/Tasks/CepUpdater.pm @@ -34,7 +34,8 @@ sub cliente_update_cep { $cep =~ s/[^0-9]//go; my $result; foreach my $backend (map { Penhas::CEP->new_with_traits(traits => $_) } qw(ViaCep Correios)) { - $result = $backend->find($cep); + $result = eval{$backend->find($cep)}; + $logger->error("Error during cep find using $backend: $@") if $@; if ($result) { # pula proximo backend se todos os campos estão preenchidos