RuntimeError-ef395448.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. define(['exports', './defaultValue-fe22d8c0'], (function (exports, defaultValue) { 'use strict';
  2. /**
  3. * Constructs an exception object that is thrown due to an error that can occur at runtime, e.g.,
  4. * out of memory, could not compile shader, etc. If a function may throw this
  5. * exception, the calling code should be prepared to catch it.
  6. * <br /><br />
  7. * On the other hand, a {@link DeveloperError} indicates an exception due
  8. * to a developer error, e.g., invalid argument, that usually indicates a bug in the
  9. * calling code.
  10. *
  11. * @alias RuntimeError
  12. * @constructor
  13. * @extends Error
  14. *
  15. * @param {string} [message] The error message for this exception.
  16. *
  17. * @see DeveloperError
  18. */
  19. function RuntimeError(message) {
  20. /**
  21. * 'RuntimeError' indicating that this exception was thrown due to a runtime error.
  22. * @type {string}
  23. * @readonly
  24. */
  25. this.name = "RuntimeError";
  26. /**
  27. * The explanation for why this exception was thrown.
  28. * @type {string}
  29. * @readonly
  30. */
  31. this.message = message;
  32. //Browsers such as IE don't have a stack property until you actually throw the error.
  33. let stack;
  34. try {
  35. throw new Error();
  36. } catch (e) {
  37. stack = e.stack;
  38. }
  39. /**
  40. * The stack trace of this exception, if available.
  41. * @type {string}
  42. * @readonly
  43. */
  44. this.stack = stack;
  45. }
  46. if (defaultValue.defined(Object.create)) {
  47. RuntimeError.prototype = Object.create(Error.prototype);
  48. RuntimeError.prototype.constructor = RuntimeError;
  49. }
  50. RuntimeError.prototype.toString = function () {
  51. let str = `${this.name}: ${this.message}`;
  52. if (defaultValue.defined(this.stack)) {
  53. str += `\n${this.stack.toString()}`;
  54. }
  55. return str;
  56. };
  57. exports.RuntimeError = RuntimeError;
  58. }));