UNPKG

@safik/fk-plug-controller

Version:

Internet Computer Plug wallet's controller

28 lines (27 loc) 996 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.checkForError = exports.isEmpty = void 0; const extensionizer_1 = __importDefault(require("extensionizer")); const isEmpty = (obj) => Object.keys(obj).length === 0; exports.isEmpty = isEmpty; /** * Returns an Error if extension.runtime.lastError is present * this is a workaround for the non-standard error object that's used * @returns {Error|undefined} */ const checkForError = () => { const { lastError } = extensionizer_1.default.runtime; if (!lastError) { return undefined; } // if it quacks like an Error, its an Error if (lastError.stack && lastError.message) { return lastError; } // repair incomplete error object (eg chromium v77) return new Error(lastError.message); }; exports.checkForError = checkForError;