diff options
Diffstat (limited to 'src/errors.lisp')
| -rw-r--r-- | src/errors.lisp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/errors.lisp b/src/errors.lisp index 525ac67..ea6f83f 100644 --- a/src/errors.lisp +++ b/src/errors.lisp @@ -30,12 +30,29 @@ Usually signalled without a request ever being made — the client checks the format before going to the network.")) (define-condition cep-not-found (cepis-error cell-error) - () + ((faixa :initarg :faixa + :initform nil + :reader cep-not-found-faixa + :documentation + "The municipality owning the band this CEP falls in, or NIL.")) + (:report (lambda (condition stream) + (write-string (error-message condition) stream) + (let ((faixa (cep-not-found-faixa condition))) + (when faixa + (format stream " — it falls in the band of ~a/~a" + (faixa-localidade faixa) + (faixa-uf faixa)))))) (:documentation "The CEP is well-formed but does not exist in the DNE database. Also a `cell-error', which is the closest thing the standard has to a failed -key lookup: `cell-error-name' returns the CEP that was not found.")) +key lookup: `cell-error-name' returns the CEP that was not found. + +`cep-not-found-faixa' is a `faixa' naming the municipality that owns the band +the CEP falls in, when the API knows one, and NIL otherwise — either because +no municipality owns that band or because an older API is answering. It is +context for the error, not an address: this is still a 404, and a caller must +not read a municipality here as a CEP that resolved.")) (define-condition network-error (cepis-error) () |