UNPKG

@microsoft/sp-webpart-base

Version:

SharePoint Framework support for building web parts

30 lines 1.04 kB
"use strict"; /** * Execute the passed in delegate and re-throw the passed exception */ Object.defineProperty(exports, "__esModule", { value: true }); exports.executeAndReThrow = void 0; var sp_diagnostics_1 = require("@microsoft/sp-diagnostics"); var sp_core_library_1 = require("@microsoft/sp-core-library"); /** * Execute the passed in delegate and re-throw a custom error. * @param method - method to execute. * @param errorToThrow - custom error to throw. * @param logSource - log source. */ function executeAndReThrow(method, errorToThrow, logSource) { sp_core_library_1.Validate.isNotNullOrUndefined(method, 'method'); try { method(); } catch (e) { // Defensive code as this method should never ever throw if (logSource) { sp_diagnostics_1._TraceLogger.logError(logSource, new Error('Error: ' + e)); } errorToThrow.innerError = e; throw errorToThrow; } } exports.executeAndReThrow = executeAndReThrow; //# sourceMappingURL=ExecuteAndReThrow.js.map