diff options
Diffstat (limited to 'errors.go')
| -rw-r--r-- | errors.go | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -84,6 +84,22 @@ type Error struct { // the client's own cap is applied to it. RetryAfter time.Duration + // Faixa is the municipality the CEP would belong to, set only on + // [ErrCEPNotFound] and only when the API could name one. It is nil for + // every other kind, and also for a CEP that falls in a numeric band the + // Correios never handed to any municipality. + // + // It turns "this CEP does not exist" into something the caller can act + // on: the city is right, the number is not. + // + // var cerr *cepis.Error + // if errors.As(err, &cerr) && cerr.Faixa != nil { + // fmt.Printf("did you mean somewhere in %s/%s? (%s to %s)\n", + // cerr.Faixa.Localidade, cerr.Faixa.UF, + // cerr.Faixa.CEPIni, cerr.Faixa.CEPFim) + // } + Faixa *Faixa + // Message describes the failure without the "cepis: " prefix. Message string |