您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

helpers.js 727B

123456789101112131415161718192021222324252627282930313233
  1. /**
  2. * Create deferred object.
  3. * @returns {{promise, resolve, reject}}
  4. */
  5. export function createDeferred () {
  6. let deferred = {};
  7. deferred.promise = new Promise(function (resolve, reject) {
  8. deferred.resolve = resolve;
  9. deferred.reject = reject;
  10. });
  11. return deferred;
  12. }
  13. /**
  14. * Reload page.
  15. */
  16. export function reload () {
  17. window.location.reload();
  18. }
  19. /**
  20. * Prints the error and reports it to the global error handler.
  21. * @param e {Error} the error
  22. * @param msg {string} [optional] the message printed in addition to the error
  23. */
  24. export function reportError (e, msg = "") {
  25. console.error(msg, e);
  26. if(window.onerror)
  27. window.onerror(msg, null, null,
  28. null, e);
  29. }