UNPKG

2.48 kBPlain TextView Raw
1// Copyright (c) .NET Foundation. All rights reserved.
2// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3
4/** Error thrown when an HTTP request fails. */
5export class HttpError extends Error {
6 // @ts-ignore: Intentionally unused.
7 // tslint:disable-next-line:variable-name
8 private __proto__: Error;
9
10 /** The HTTP status code represented by this error. */
11 public statusCode: number;
12
13 /** Constructs a new instance of {@link @microsoft/signalr.HttpError}.
14 *
15 * @param {string} errorMessage A descriptive error message.
16 * @param {number} statusCode The HTTP status code represented by this error.
17 */
18 constructor(errorMessage: string, statusCode: number) {
19 const trueProto = new.target.prototype;
20 super(errorMessage);
21 this.statusCode = statusCode;
22
23 // Workaround issue in Typescript compiler
24 // https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
25 this.__proto__ = trueProto;
26 }
27}
28
29/** Error thrown when a timeout elapses. */
30export class TimeoutError extends Error {
31 // @ts-ignore: Intentionally unused.
32 // tslint:disable-next-line:variable-name
33 private __proto__: Error;
34
35 /** Constructs a new instance of {@link @microsoft/signalr.TimeoutError}.
36 *
37 * @param {string} errorMessage A descriptive error message.
38 */
39 constructor(errorMessage: string = "A timeout occurred.") {
40 const trueProto = new.target.prototype;
41 super(errorMessage);
42
43 // Workaround issue in Typescript compiler
44 // https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
45 this.__proto__ = trueProto;
46 }
47}
48
49/** Error thrown when an action is aborted. */
50export class AbortError extends Error {
51 // @ts-ignore: Intentionally unused.
52 // tslint:disable-next-line:variable-name
53 private __proto__: Error;
54
55 /** Constructs a new instance of {@link AbortError}.
56 *
57 * @param {string} errorMessage A descriptive error message.
58 */
59 constructor(errorMessage: string = "An abort occurred.") {
60 const trueProto = new.target.prototype;
61 super(errorMessage);
62
63 // Workaround issue in Typescript compiler
64 // https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
65 this.__proto__ = trueProto;
66 }
67}