diff options
author | Marius Bakke <mbakke@fastmail.com> | 2020-03-14 13:13:40 +0100 |
---|---|---|
committer | Marius Bakke <mbakke@fastmail.com> | 2020-03-14 13:13:40 +0100 |
commit | 961d2ee2695b38503b463d055e9c7edbcc0bf307 (patch) | |
tree | 82d9b40477a1d4d88e75a187b2b637a56751480b /guix/inferior.scm | |
parent | 7cf79d7a51ff5dde4fc430fab2296b5f7de08953 (diff) | |
parent | aebba13c0bef5a58697f1a9fe8337967cc01300f (diff) | |
download | guix-patches-961d2ee2695b38503b463d055e9c7edbcc0bf307.tar guix-patches-961d2ee2695b38503b463d055e9c7edbcc0bf307.tar.gz |
Merge branch 'master' into core-updates
Diffstat (limited to 'guix/inferior.scm')
-rw-r--r-- | guix/inferior.scm | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/guix/inferior.scm b/guix/inferior.scm index 0236fb61ad..6b685ece30 100644 --- a/guix/inferior.scm +++ b/guix/inferior.scm @@ -63,6 +63,9 @@ inferior-eval inferior-eval-with-store inferior-object? + inferior-exception? + inferior-exception-arguments + inferior-exception-inferior read-repl-response inferior-packages @@ -195,8 +198,15 @@ equivalent. Return #f if the inferior could not be launched." (set-record-type-printer! <inferior-object> write-inferior-object) -(define (read-repl-response port) - "Read a (guix repl) response from PORT and return it as a Scheme object." +;; Reified exception thrown by an inferior. +(define-condition-type &inferior-exception &error + inferior-exception? + (arguments inferior-exception-arguments) ;key + arguments + (inferior inferior-exception-inferior)) ;<inferior> | #f + +(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." (define sexp->object (match-lambda (('value value) @@ -208,10 +218,13 @@ equivalent. Return #f if the inferior could not be launched." (('values objects ...) (apply values (map sexp->object objects))) (('exception key objects ...) - (apply throw key (map sexp->object objects))))) + (raise (condition (&inferior-exception + (arguments (cons key (map sexp->object objects))) + (inferior inferior))))))) (define (read-inferior-response inferior) - (read-repl-response (inferior-socket inferior))) + (read-repl-response (inferior-socket inferior) + inferior)) (define (send-inferior-request exp inferior) (write exp (inferior-socket inferior)) |