From 0c1ff5bccf33166fdd90aa3e30b68df34ce38665 Mon Sep 17 00:00:00 2001 From: Alf Eaton Date: Tue, 17 May 2022 15:12:47 +0100 Subject: [PATCH] Avoid class properties shorthand in FetchError constructor (#8002) GitOrigin-RevId: e210fc7d8104a8e4240efc8d0192aceafe07af61 --- .../frontend/js/infrastructure/fetch-json.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/services/web/frontend/js/infrastructure/fetch-json.ts b/services/web/frontend/js/infrastructure/fetch-json.ts index 689f1bb50f..b3f3f70b89 100644 --- a/services/web/frontend/js/infrastructure/fetch-json.ts +++ b/services/web/frontend/js/infrastructure/fetch-json.ts @@ -48,12 +48,17 @@ function getErrorMessageForStatusCode(statusCode?: number) { } export class FetchError extends OError { + public url: string + public options?: RequestInit + public response?: Response + public data?: any + constructor( message: string, - public url: string, - public options?: RequestInit, - public response?: Response, - public data?: any + url: string, + options?: RequestInit, + response?: Response, + data?: any ) { // On HTTP2, the `statusText` property is not set, // so this `message` will be undefined. We need to @@ -62,7 +67,13 @@ export class FetchError extends OError { if (!message) { message = getErrorMessageForStatusCode(response?.status) } + super(message, { statusCode: response ? response.status : undefined }) + + this.url = url + this.options = options + this.response = response + this.data = data } getUserFacingMessage() {