UNPKG

@snipsonian/core

Version:

Core/base reusable javascript code snippets

19 lines (18 loc) 485 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function conditionalCatch({ actionToExecute, onError, shouldCatchErrors = false, }) { if (shouldCatchErrors) { try { return actionToExecute(); } catch (error) { if (typeof onError === 'function') { return onError(error); } } } else { return actionToExecute(); } } exports.default = conditionalCatch;