Errors.js 5.6 KB

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