• 凡是没有提供 Promise 的 chrome api 都需要这个方法来捕获 chrome.runtime.lastError 报错。

    Type Parameters

    • T extends ((...params) => any)

    Parameters

    • api: T

      需要执行的 api 方法

    • Rest ...params: Parameters<T>

    Returns ReturnType<T>

    返回原 api 调用的返回值

    Example

    catchLastError(chrome.contextMenus.create, {
    id: 'save',
    title: '保存',
    contexts: ['page'],
    })