add catch for redis client fail
Some checks failed
Build and push image for doorman / docker (push) Failing after 22s

This commit is contained in:
Martin Dimitrov 2024-05-04 20:58:24 -07:00
parent 9e96286390
commit 9ddb91472d
3 changed files with 20 additions and 2 deletions

View File

@ -45,12 +45,18 @@ exports.handler = function(context, event, callback) {
await client.set(statusKey, JSON.stringify(fingerprint)); await client.set(statusKey, JSON.stringify(fingerprint));
await client.expire(statusKey, timeout); await client.expire(statusKey, timeout);
await client.quit(); await client.quit();
response response
.setStatusCode(200) .setStatusCode(200)
.appendHeader('Content-Type', 'application/json') .appendHeader('Content-Type', 'application/json')
.setBody({ msg: `Opened the door "${door}" for ${timeout}s` }); .setBody({ msg: `Opened the door "${door}" for ${timeout}s` });
return callback(null, response); return callback(null, response);
}).catch((e) => {
console.log(e);
response
.setStatusCode(500)
.appendHeader('Content-Type', 'application/json')
.setBody({ err: e });
}); });
}; };

View File

@ -36,5 +36,11 @@ exports.handler = function(context, event, callback) {
.setBody({ id: door, timeout, status }); .setBody({ id: door, timeout, status });
return callback(null, response); return callback(null, response);
}).catch((e) => {
console.log(e);
response
.setStatusCode(500)
.appendHeader('Content-Type', 'application/json')
.setBody({ err: e });
}); });
}; };

View File

@ -51,5 +51,11 @@ exports.handler = function(context, event, callback) {
}); });
return callback(null, response); return callback(null, response);
}); }).catch((e) => {
console.log(e);
response
.setStatusCode(500)
.appendHeader('Content-Type', 'application/json')
.setBody({ err: e });
});;
}; };