jiti-meet/modules/util/helpers.js

29 lines
688 B
JavaScript
Raw Normal View History

const logger = require('jitsi-meet-logger').getLogger(__filename);
2016-11-11 15:00:54 +00:00
/**
* Create deferred object.
*
* @returns {{promise, resolve, reject}}
*/
export function createDeferred() {
const deferred = {};
deferred.promise = new Promise((resolve, reject) => {
deferred.resolve = resolve;
deferred.reject = reject;
});
return deferred;
}
2016-02-05 15:04:48 +00:00
/**
* Prints the error and reports it to the global error handler.
*
* @param e {Error} the error
* @param msg {string} [optional] the message printed in addition to the error
*/
export function reportError(e, msg = '') {
logger.error(msg, e);
window.onerror && window.onerror(msg, null, null, null, e);
}