return error message on missing argument 'state'

This commit is contained in:
Daniel Sommer 2022-03-25 16:32:26 +01:00
parent 99c588ac13
commit 4c7654722d

View file

@ -18,7 +18,9 @@ async function setServiceState(name, args) {
} }
let state = args.get('state'); let state = args.get('state');
if (state === undefined) { 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) { 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 + '\''; const msg = 'can not set state of service \'' + name + '\' to unknown state \'' + state + '\'';