UNPKG

@microsoft/sp-webpart-base

Version:

SharePoint Framework support for building web parts

29 lines 1.05 kB
"use strict"; /** * Execute the passed delegate and eat up the exception stack. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.executeWithoutFailing = 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 with a guarantee that no exception will leak out. * Do not use this normally. Only in error handling scenarios where you would like * to be defesive. * @param method - method to execute. * @param logSource - log source. */ function executeWithoutFailing(method, 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)); } } } exports.executeWithoutFailing = executeWithoutFailing; //# sourceMappingURL=ExecuteWithoutFailing.js.map