UNPKG

1.02 kBPlain TextView Raw
1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT License. See License.txt in the project root for license information.
3
4import { HttpOperationResponse } from "./httpOperationResponse";
5import { WebResourceLike } from "./webResource";
6
7export class RestError extends Error {
8 static readonly REQUEST_SEND_ERROR: string = "REQUEST_SEND_ERROR";
9 static readonly REQUEST_ABORTED_ERROR: string = "REQUEST_ABORTED_ERROR";
10 static readonly PARSE_ERROR: string = "PARSE_ERROR";
11
12 code?: string;
13 statusCode?: number;
14 request?: WebResourceLike;
15 response?: HttpOperationResponse;
16 body?: any;
17 constructor(
18 message: string,
19 code?: string,
20 statusCode?: number,
21 request?: WebResourceLike,
22 response?: HttpOperationResponse,
23 body?: any
24 ) {
25 super(message);
26 this.code = code;
27 this.statusCode = statusCode;
28 this.request = request;
29 this.response = response;
30 this.body = body;
31
32 Object.setPrototypeOf(this, RestError.prototype);
33 }
34}