// Copyright 2019-2022 @polkadot/extension authors & contributors // SPDX-License-Identifier: Apache-2.0 export function withErrorLog (fn: () => unknown): void { try { const p = fn(); if (p && typeof p === 'object' && typeof (p as Promise).catch === 'function') { (p as Promise).catch(console.error); } } catch (e) { console.error(e); } }