summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2022-11-22 07:16:03 +0100
committerLudovic Courtès <ludo@gnu.org>2022-11-22 09:43:54 +0100
commit60bea075938cae10147d1d8fd414dc0140f4118f (patch)
treeda223958b7d3b7a453d1f2793bb5abd1ee413f4d
parent47ba3f7d25fadb12b78d2728941e4e677fd7ad0e (diff)
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.
-rw-r--r--guix/inferior.scm12
1 files changed, 11 insertions, 1 deletions
diff --git a/guix/inferior.scm b/guix/inferior.scm
index 2fe34ca0dc..defdcc4e48 100644
--- a/guix/inferior.scm
+++ b/guix/inferior.scm
@@ -69,6 +69,8 @@
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 @@ equivalent. Return #f if the inferior could not be launched."
(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 @@ Raise '&inferior-exception' when an exception is read from PORT."
(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)