From 4c7654722d7bb32bf3d8e1e5a4b0bf570ccb3799 Mon Sep 17 00:00:00 2001 From: velvettear Date: Fri, 25 Mar 2022 16:32:26 +0100 Subject: [PATCH] return error message on missing argument 'state' --- libs/systemd.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/systemd.js b/libs/systemd.js index 9254096..34647b6 100644 --- a/libs/systemd.js +++ b/libs/systemd.js @@ -18,7 +18,9 @@ async function setServiceState(name, args) { } let state = args.get('state'); if (state === undefined) { - return; + const msg = 'missing argument \'state\', pass either \'active\', \'inactive\' or \'toggle\''; + logger.debug(msg); + return { err: msg }; } if (state !== constants.SYSTEMD_STATE_ACTIVE && state !== constants.SYSTEMD_STATE_INACTIVE && state !== constants.SYSTEMD_STATE_TOGGLE) { const msg = 'can not set state of service \'' + name + '\' to unknown state \'' + state + '\'';