[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[shepherd] 05/05: shepherd: Properly report ‘&message’ exceptions from c
From: |
Ludovic Courtès |
Subject: |
[shepherd] 05/05: shepherd: Properly report ‘&message’ exceptions from config file. |
Date: |
Fri, 10 May 2024 19:04:31 -0400 (EDT) |
civodul pushed a commit to branch devel
in repository shepherd.
commit 42d89407e7fd1740496b6f188a2078d30b87b642
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Fri May 10 22:59:04 2024 +0200
shepherd: Properly report ‘&message’ exceptions from config file.
* modules/shepherd.scm (configuration-file-loader): Add
‘message-condition?’ clause and ‘else’ clause.
* tests/services/timer.sh: Test error reporting for invalid
‘calendar-event’ arguments.
---
modules/shepherd.scm | 10 ++++++++++
tests/services/timer.sh | 14 ++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/modules/shepherd.scm b/modules/shepherd.scm
index f7e302b..490cf65 100644
--- a/modules/shepherd.scm
+++ b/modules/shepherd.scm
@@ -186,6 +186,16 @@ using fallback mechanism."))
((exception-with-kind-and-args? c)
(handle-key-and-args-exception
(exception-kind c) (exception-args c))
+ (failure))
+ ((message-condition? c)
+ (local-output
+ (l10n "Error while loading configuration file '~a': ~a")
+ file (condition-message c))
+ (failure))
+ (else
+ (local-output (l10n "Uncaught exception while loading \
+configuration file '~a': ~s")
+ file c)
(failure)))
(load-in-user-module file)
(local-output (l10n "Configuration successfully loaded from '~a'.")
diff --git a/tests/services/timer.sh b/tests/services/timer.sh
index 2158a43..09f9011 100644
--- a/tests/services/timer.sh
+++ b/tests/services/timer.sh
@@ -120,3 +120,17 @@ $herd trigger never-timer
until grep "Triggered from $PWD" "$log"; do sleep 0.3; done
$herd stop root
+
+while kill -0 "$(cat $pid)" ; do sleep 0.2; done
+
+# Check error reports when config is invalid.
+cat > "$conf" <<EOF
+(use-modules (shepherd service timer))
+
+(calendar-event #:days-of-week '(1 2 3)) ;wrong!
+EOF
+rm -f "$pid"
+shepherd -I -s "$socket" -c "$conf" -l "$log" --pid="$pid" &
+until grep "invalid day of week" "$log"; do sleep 0.2; done
+
+$herd stop root