inferior: Raise '&inferior-protocol-error' on invalid response.

* guix/inferior.scm (&inferior-protocol-error): New condition type.
(read-repl-response): Add default 'match' clause and raise it.
This commit is contained in:
Ludovic Courtès 2022-11-22 07:16:03 +01:00
parent 47ba3f7d25
commit 60bea07593
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -69,6 +69,8 @@ (define-module (guix inferior)
inferior-exception-arguments
inferior-exception-inferior
inferior-exception-stack
inferior-protocol-error?
inferior-protocol-error-inferior
read-repl-response
inferior-packages
@ -314,6 +316,10 @@ (define-condition-type &inferior-exception &error
(inferior inferior-exception-inferior) ;<inferior> | #f
(stack inferior-exception-stack)) ;list of (FILE COLUMN LINE)
(define-condition-type &inferior-protocol-error &error
inferior-protocol-error?
(inferior inferior-protocol-error-inferior)) ;<inferior>
(define* (read-repl-response port #:optional inferior)
"Read a (guix repl) response from PORT and return it as a Scheme object.
Raise '&inferior-exception' when an exception is read from PORT."
@ -339,7 +345,11 @@ (define sexp->object
(raise (condition (&inferior-exception
(arguments (cons key (map sexp->object objects)))
(inferior inferior)
(stack '())))))))
(stack '())))))
(_
;; Protocol error.
(raise (condition (&inferior-protocol-error
(inferior inferior)))))))
(define (read-inferior-response inferior)
(read-repl-response (inferior-socket inferior)