Skip to content

Commit

Permalink
Ignorar erros (throws) a cada find, para que todos os backends sejam …
Browse files Browse the repository at this point in the history
…testados
  • Loading branch information
renatocron committed Dec 15, 2023
1 parent c7f0df8 commit a676fe2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion api/lib/Penhas/Controller/SignUp.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion api/lib/Penhas/Minion/Tasks/CepUpdater.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a676fe2

Please sign in to comment.