summaryrefslogtreecommitdiffstats
path: root/app/main.f90
diff options
context:
space:
mode:
Diffstat (limited to 'app/main.f90')
-rw-r--r--app/main.f9014
1 files changed, 14 insertions, 0 deletions
diff --git a/app/main.f90 b/app/main.f90
index 5e3f988..0029d6e 100644
--- a/app/main.f90
+++ b/app/main.f90
@@ -109,6 +109,7 @@ contains
call handle%lookup(cep, address, code, detail)
if (code /= CEPIS_OK) then
write (error_unit, '(A)') 'cepis: '//cepis_status_name(code)//': '//detail
+ if (address%has_faixa) call show_faixa(address%faixa)
stop 1
end if
@@ -132,6 +133,19 @@ contains
end if
end subroutine show_one
+ !> What the API knows about a CEP that does not exist: the municipality it
+ !> would have fallen under. The lookup still failed, so this goes to stderr
+ !> with the error, and the exit status stays 1.
+ subroutine show_faixa(faixa)
+ type(cepis_faixa), intent(in) :: faixa
+
+ write (error_unit, '(A)') ' faixa '//faixa%localidade//'/'// &
+ faixa%uf//' ibge '//faixa%ibge
+ write (error_unit, '(A,I0,A)') ' existentes '//faixa%formatted_cep_ini()// &
+ '..'//faixa%formatted_cep_fim()//' ', faixa%ceps, &
+ ' CEPs (the range is sparse; most numbers in it do not exist)'
+ end subroutine show_faixa
+
subroutine show_many(handle, values)
type(cepis_client), intent(in) :: handle
character(len=*), intent(in) :: values(:)