Errors.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. "use strict";
  2. // Licensed to the .NET Foundation under one or more agreements.
  3. // The .NET Foundation licenses this file to you under the MIT license.
  4. Object.defineProperty(exports, "__esModule", { value: true });
  5. exports.AggregateErrors = exports.FailedToNegotiateWithServerError = exports.FailedToStartTransportError = exports.DisabledTransportError = exports.UnsupportedTransportError = exports.AbortError = exports.TimeoutError = exports.HttpError = void 0;
  6. /** Error thrown when an HTTP request fails. */
  7. class HttpError extends Error {
  8. /** Constructs a new instance of {@link @microsoft/signalr.HttpError}.
  9. *
  10. * @param {string} errorMessage A descriptive error message.
  11. * @param {number} statusCode The HTTP status code represented by this error.
  12. */
  13. constructor(errorMessage, statusCode) {
  14. const trueProto = new.target.prototype;
  15. super(`${errorMessage}: Status code '${statusCode}'`);
  16. this.statusCode = statusCode;
  17. // Workaround issue in Typescript compiler
  18. // https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
  19. this.__proto__ = trueProto;
  20. }
  21. }
  22. exports.HttpError = HttpError;
  23. /** Error thrown when a timeout elapses. */
  24. class TimeoutError extends Error {
  25. /** Constructs a new instance of {@link @microsoft/signalr.TimeoutError}.
  26. *
  27. * @param {string} errorMessage A descriptive error message.
  28. */
  29. constructor(errorMessage = "A timeout occurred.") {
  30. const trueProto = new.target.prototype;
  31. super(errorMessage);
  32. // Workaround issue in Typescript compiler
  33. // https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
  34. this.__proto__ = trueProto;
  35. }
  36. }
  37. exports.TimeoutError = TimeoutError;
  38. /** Error thrown when an action is aborted. */
  39. class AbortError extends Error {
  40. /** Constructs a new instance of {@link AbortError}.
  41. *
  42. * @param {string} errorMessage A descriptive error message.
  43. */
  44. constructor(errorMessage = "An abort occurred.") {
  45. const trueProto = new.target.prototype;
  46. super(errorMessage);
  47. // Workaround issue in Typescript compiler
  48. // https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
  49. this.__proto__ = trueProto;
  50. }
  51. }
  52. exports.AbortError = AbortError;
  53. /** Error thrown when the selected transport is unsupported by the browser. */
  54. /** @private */
  55. class UnsupportedTransportError extends Error {
  56. /** Constructs a new instance of {@link @microsoft/signalr.UnsupportedTransportError}.
  57. *
  58. * @param {string} message A descriptive error message.
  59. * @param {HttpTransportType} transport The {@link @microsoft/signalr.HttpTransportType} this error occurred on.
  60. */
  61. constructor(message, transport) {
  62. const trueProto = new.target.prototype;
  63. super(message);
  64. this.transport = transport;
  65. this.errorType = 'UnsupportedTransportError';
  66. // Workaround issue in Typescript compiler
  67. // https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
  68. this.__proto__ = trueProto;
  69. }
  70. }
  71. exports.UnsupportedTransportError = UnsupportedTransportError;
  72. /** Error thrown when the selected transport is disabled by the browser. */
  73. /** @private */
  74. class DisabledTransportError extends Error {
  75. /** Constructs a new instance of {@link @microsoft/signalr.DisabledTransportError}.
  76. *
  77. * @param {string} message A descriptive error message.
  78. * @param {HttpTransportType} transport The {@link @microsoft/signalr.HttpTransportType} this error occurred on.
  79. */
  80. constructor(message, transport) {
  81. const trueProto = new.target.prototype;
  82. super(message);
  83. this.transport = transport;
  84. this.errorType = 'DisabledTransportError';
  85. // Workaround issue in Typescript compiler
  86. // https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
  87. this.__proto__ = trueProto;
  88. }
  89. }
  90. exports.DisabledTransportError = DisabledTransportError;
  91. /** Error thrown when the selected transport cannot be started. */
  92. /** @private */
  93. class FailedToStartTransportError extends Error {
  94. /** Constructs a new instance of {@link @microsoft/signalr.FailedToStartTransportError}.
  95. *
  96. * @param {string} message A descriptive error message.
  97. * @param {HttpTransportType} transport The {@link @microsoft/signalr.HttpTransportType} this error occurred on.
  98. */
  99. constructor(message, transport) {
  100. const trueProto = new.target.prototype;
  101. super(message);
  102. this.transport = transport;
  103. this.errorType = 'FailedToStartTransportError';
  104. // Workaround issue in Typescript compiler
  105. // https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
  106. this.__proto__ = trueProto;
  107. }
  108. }
  109. exports.FailedToStartTransportError = FailedToStartTransportError;
  110. /** Error thrown when the negotiation with the server failed to complete. */
  111. /** @private */
  112. class FailedToNegotiateWithServerError extends Error {
  113. /** Constructs a new instance of {@link @microsoft/signalr.FailedToNegotiateWithServerError}.
  114. *
  115. * @param {string} message A descriptive error message.
  116. */
  117. constructor(message) {
  118. const trueProto = new.target.prototype;
  119. super(message);
  120. this.errorType = 'FailedToNegotiateWithServerError';
  121. // Workaround issue in Typescript compiler
  122. // https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
  123. this.__proto__ = trueProto;
  124. }
  125. }
  126. exports.FailedToNegotiateWithServerError = FailedToNegotiateWithServerError;
  127. /** Error thrown when multiple errors have occurred. */
  128. /** @private */
  129. class AggregateErrors extends Error {
  130. /** Constructs a new instance of {@link @microsoft/signalr.AggregateErrors}.
  131. *
  132. * @param {string} message A descriptive error message.
  133. * @param {Error[]} innerErrors The collection of errors this error is aggregating.
  134. */
  135. constructor(message, innerErrors) {
  136. const trueProto = new.target.prototype;
  137. super(message);
  138. this.innerErrors = innerErrors;
  139. // Workaround issue in Typescript compiler
  140. // https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
  141. this.__proto__ = trueProto;
  142. }
  143. }
  144. exports.AggregateErrors = AggregateErrors;
  145. //# sourceMappingURL=Errors.js.map