restError.ts 977 B

123456789101112131415161718192021222324252627
  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. import { HttpOperationResponse } from "./httpOperationResponse";
  4. import { WebResource } from "./webResource";
  5. export class RestError extends Error {
  6. static readonly REQUEST_SEND_ERROR: string = "REQUEST_SEND_ERROR";
  7. static readonly REQUEST_ABORTED_ERROR: string = "REQUEST_ABORTED_ERROR";
  8. static readonly PARSE_ERROR: string = "PARSE_ERROR";
  9. code?: string;
  10. statusCode?: number;
  11. request?: WebResource;
  12. response?: HttpOperationResponse;
  13. body?: any;
  14. constructor(message: string, code?: string, statusCode?: number, request?: WebResource, response?: HttpOperationResponse, body?: any) {
  15. super(message);
  16. this.code = code;
  17. this.statusCode = statusCode;
  18. this.request = request;
  19. this.response = response;
  20. this.body = body;
  21. Object.setPrototypeOf(this, RestError.prototype);
  22. }
  23. }