|
1 | 1 | // Licensed to the .NET Foundation under one or more agreements.
|
2 | 2 | // The .NET Foundation licenses this file to you under the MIT license.
|
3 | 3 |
|
| 4 | +import { HttpTransportType } from "./ITransport"; |
| 5 | + |
4 | 6 | /** Error thrown when an HTTP request fails. */
|
5 | 7 | export class HttpError extends Error {
|
6 | 8 | // @ts-ignore: Intentionally unused.
|
@@ -65,3 +67,104 @@ export class AbortError extends Error {
|
65 | 67 | this.__proto__ = trueProto;
|
66 | 68 | }
|
67 | 69 | }
|
| 70 | + |
| 71 | +/** Error thrown when the selected transport is unsupported by the browser. */ |
| 72 | +export class UnsupportedTransportError extends Error { |
| 73 | + // @ts-ignore: Intentionally unused. |
| 74 | + // eslint-disable-next-line @typescript-eslint/naming-convention |
| 75 | + private __proto__: Error; |
| 76 | + |
| 77 | + /** The {@link @microsoft/signalr.HttpTransportType} this error occured on. */ |
| 78 | + public transport: HttpTransportType; |
| 79 | + |
| 80 | + /** Constructs a new instance of {@link @microsoft/signalr.UnsupportedTransportError}. |
| 81 | + * |
| 82 | + * @param {string} message A descriptive error message. |
| 83 | + * @param {HttpTransportType} transport The {@link @microsoft/signalr.HttpTransportType} this error occured on. |
| 84 | + */ |
| 85 | + constructor(message: string, transport: HttpTransportType) { |
| 86 | + const trueProto = new.target.prototype; |
| 87 | + super(message); |
| 88 | + this.transport = transport; |
| 89 | + |
| 90 | + // Workaround issue in Typescript compiler |
| 91 | + // https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200 |
| 92 | + this.__proto__ = trueProto; |
| 93 | + } |
| 94 | +} |
| 95 | + |
| 96 | +/** Error thrown when the selected transport is disabled by the browser. */ |
| 97 | +export class DisabledTransportError extends Error { |
| 98 | + // @ts-ignore: Intentionally unused. |
| 99 | + // eslint-disable-next-line @typescript-eslint/naming-convention |
| 100 | + private __proto__: Error; |
| 101 | + |
| 102 | + /** The {@link @microsoft/signalr.HttpTransportType} this error occured on. */ |
| 103 | + public transport: HttpTransportType; |
| 104 | + |
| 105 | + /** Constructs a new instance of {@link @microsoft/signalr.DisabledTransportError}. |
| 106 | + * |
| 107 | + * @param {string} message A descriptive error message. |
| 108 | + * @param {HttpTransportType} transport The {@link @microsoft/signalr.HttpTransportType} this error occured on. |
| 109 | + */ |
| 110 | + constructor(message: string, transport: HttpTransportType) { |
| 111 | + const trueProto = new.target.prototype; |
| 112 | + super(message); |
| 113 | + this.transport = transport; |
| 114 | + |
| 115 | + // Workaround issue in Typescript compiler |
| 116 | + // https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200 |
| 117 | + this.__proto__ = trueProto; |
| 118 | + } |
| 119 | +} |
| 120 | + |
| 121 | +/** Error thrown when the selected transport cannot be started. */ |
| 122 | +export class FailedToStartTransportError extends Error { |
| 123 | + // @ts-ignore: Intentionally unused. |
| 124 | + // eslint-disable-next-line @typescript-eslint/naming-convention |
| 125 | + private __proto__: Error; |
| 126 | + |
| 127 | + /** The {@link @microsoft/signalr.HttpTransportType} this error occured on. */ |
| 128 | + public transport: HttpTransportType; |
| 129 | + |
| 130 | + /** Constructs a new instance of {@link @microsoft/signalr.FailedToStartTransportError}. |
| 131 | + * |
| 132 | + * @param {string} message A descriptive error message. |
| 133 | + * @param {HttpTransportType} transport The {@link @microsoft/signalr.HttpTransportType} this error occured on. |
| 134 | + */ |
| 135 | + constructor(message: string, transport: HttpTransportType) { |
| 136 | + const trueProto = new.target.prototype; |
| 137 | + super(message); |
| 138 | + this.transport = transport; |
| 139 | + |
| 140 | + // Workaround issue in Typescript compiler |
| 141 | + // https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200 |
| 142 | + this.__proto__ = trueProto; |
| 143 | + } |
| 144 | +} |
| 145 | + |
| 146 | +/** Error thrown when multiple errors have occured. */ |
| 147 | +export class AggregateErrors extends Error { |
| 148 | + // @ts-ignore: Intentionally unused. |
| 149 | + // eslint-disable-next-line @typescript-eslint/naming-convention |
| 150 | + private __proto__: Error; |
| 151 | + |
| 152 | + /** The collection of errors this error is aggregating. */ |
| 153 | + public innerErrors: Error[]; |
| 154 | + |
| 155 | + /** Constructs a new instance of {@link @microsoft/signalr.AggregateErrors}. |
| 156 | + * |
| 157 | + * @param {string} message A descriptive error message. |
| 158 | + * @param {Error[]} innerErrors The collection of errors this error is aggregating. |
| 159 | + */ |
| 160 | + constructor(message: string, innerErrors: Error[]) { |
| 161 | + const trueProto = new.target.prototype; |
| 162 | + super(message); |
| 163 | + |
| 164 | + this.innerErrors = innerErrors; |
| 165 | + |
| 166 | + // Workaround issue in Typescript compiler |
| 167 | + // https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200 |
| 168 | + this.__proto__ = trueProto; |
| 169 | + } |
| 170 | +} |
0 commit comments