[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[shepherd] 04/07: comm: Add 'report-command-error'.
From: |
Ludovic Courtès |
Subject: |
[shepherd] 04/07: comm: Add 'report-command-error'. |
Date: |
Fri, 22 Jan 2016 23:36:59 +0000 |
civodul pushed a commit to branch master
in repository shepherd.
commit 002618342cd92323afe0f57b412de30608b4a785
Author: Ludovic Courtès <address@hidden>
Date: Fri Jan 22 23:33:08 2016 +0100
comm: Add 'report-command-error'.
* modules/herd.scm (run-command): Move error interpretation to...
* modules/shepherd/comm.scm (report-command-error): ... here. New
procedure.
---
modules/herd.scm | 17 +----------------
modules/shepherd/comm.scm | 23 +++++++++++++++++++++++
2 files changed, 24 insertions(+), 16 deletions(-)
diff --git a/modules/herd.scm b/modules/herd.scm
index c7b6449..bc6c578 100644
--- a/modules/herd.scm
+++ b/modules/herd.scm
@@ -130,22 +130,7 @@ the daemon via SOCKET-FILE."
('result _) ('error error)
('messages messages))
(for-each display-line messages)
- (match error
- (('error ('version 0 _ ...) 'service-not-found service)
- (report-error (l10n "service ~a could not be found")
- service))
- (('error ('version 0 _ ...) 'action-not-found action service)
- (report-error (l10n "service ~a does not have an action ~a")
- service action))
- (('error ('version 0 _ ...) 'action-exception action service
- key (args ...))
- (report-error (l10n "exception caught while executing '~a' \
-on service '~a':")
- action service)
- (print-exception (current-error-port) #f key args))
- (('error . _)
- (report-error (l10n "something went wrong: ~s")
- error)))
+ (report-command-error error)
(exit 1))
((? eof-object?)
;; When stopping shepherd, we may get an EOF in lieu of a real reply,
diff --git a/modules/shepherd/comm.scm b/modules/shepherd/comm.scm
index 2402e7e..1c086fe 100644
--- a/modules/shepherd/comm.scm
+++ b/modules/shepherd/comm.scm
@@ -46,6 +46,7 @@
write-reply
result->sexp
+ report-command-error
start-logging
stop-logging
@@ -145,6 +146,28 @@ return the socket."
(define-method (result->sexp (kw <keyword>)) kw)
(define-method (result->sexp (obj <top>)) (object->string obj))
+(define (report-command-error error)
+ "Report ERROR, an sexp received by a shepherd client in reply to COMMAND, a
+command object."
+ (match error
+ (('error ('version 0 _ ...) 'service-not-found service)
+ (report-error (l10n "service '~a' could not be found")
+ service))
+ (('error ('version 0 _ ...) 'action-not-found action service)
+ (report-error (l10n "service '~a' does not have an action ~a")
+ service action))
+ (('error ('version 0 _ ...) 'action-exception action service
+ key (args ...))
+ (report-error (l10n "exception caught while executing '~a' \
+on service '~a':")
+ action service)
+ (print-exception (current-error-port) #f key args))
+ (('error . _)
+ (report-error (l10n "something went wrong: ~s")
+ error))
+ (#f ;not an error
+ #t)))
+
;; Port for logging. This must always be a valid port, never `#f'.
- [shepherd] branch master updated (852341e -> 28ed7e1), Ludovic Courtès, 2016/01/22
- [shepherd] 01/07: herd: Report errors according to the GNU standards., Ludovic Courtès, 2016/01/22
- [shepherd] 03/07: support: Add 'display-line'., Ludovic Courtès, 2016/01/22
- [shepherd] 04/07: comm: Add 'report-command-error'.,
Ludovic Courtès <=
- [shepherd] 05/07: reboot, halt: Adjust to sexp replies., Ludovic Courtès, 2016/01/22
- [shepherd] 07/07: Rename 'dmd-output-port' to 'shepherd-output-port'., Ludovic Courtès, 2016/01/22
- [shepherd] 02/07: Move 'report-error' to (shepherd support)., Ludovic Courtès, 2016/01/22
- [shepherd] 06/07: shepherd: Ignore SIGPIPE., Ludovic Courtès, 2016/01/22