Handle errors during "fetch" action (#44)

This commit is contained in:
Maxim Baz
2019-03-16 14:03:42 +01:00
committed by GitHub
parent 423a9bbb43
commit 53e7383042

View File

@@ -333,12 +333,21 @@ async function handleMessage(settings, message, sendResponse) {
// check that action is present
if (typeof message !== "object" || !message.hasOwnProperty("action")) {
sendResponse({ status: "error", message: "Action is missing" });
return;
}
// fetch file & parse fields if a login entry is present
try {
if (typeof message.login !== "undefined") {
await parseFields(settings, message.login);
}
} catch (e) {
sendResponse({
status: "error",
message: "Unable to fetch and parse login fields: " + e.toString()
});
return;
}
// route action
switch (message.action) {