improve error handling
This commit is contained in:
		| @ -153,7 +153,8 @@ function sendMessage(tab, req, cond, interval) { | ||||
|             console.log("request for", req.from); | ||||
|             let tabAvailable = await getTabByID(tab.id); | ||||
|             if (!tabAvailable) { | ||||
|                 throw new Error("Task interupted due to the target tab is closed."); | ||||
|                 reject("Task interupted due to the target tab is closed."); | ||||
|                 return; | ||||
|             } | ||||
|  | ||||
|             chrome.tabs.sendMessage(tab.id, req, r => { | ||||
| @ -183,6 +184,7 @@ async function getActiveTab(currentWindow) { | ||||
| async function getTabByID(id) { | ||||
|     return new Promise((resolve, reject) => { | ||||
|         chrome.tabs.get(id, function (tab) { | ||||
|             chrome.runtime.lastError; | ||||
|             resolve(tab); | ||||
|         }) | ||||
|     }) | ||||
|  | ||||
		Reference in New Issue
	
	Block a user