From 3bbb58dcc2d791f80399abb12ceef83076005ac8 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 4 Feb 2022 15:42:01 -0500 Subject: [PATCH] - fixes error throw in typescript request adapter Signed-off-by: Vincent Biret --- abstractions/typescript/src/apiError.ts | 1 + http/typescript/fetch/src/fetchRequestAdapter.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/abstractions/typescript/src/apiError.ts b/abstractions/typescript/src/apiError.ts index dfc158f35f..5a990f1c83 100644 --- a/abstractions/typescript/src/apiError.ts +++ b/abstractions/typescript/src/apiError.ts @@ -5,5 +5,6 @@ export class ApiError implements Error { public stack?: string; public constructor(message?: string) { this.message = message || ""; + this.name = "ApiError"; } } \ No newline at end of file diff --git a/http/typescript/fetch/src/fetchRequestAdapter.ts b/http/typescript/fetch/src/fetchRequestAdapter.ts index 40f639affe..9daabcc2fa 100644 --- a/http/typescript/fetch/src/fetchRequestAdapter.ts +++ b/http/typescript/fetch/src/fetchRequestAdapter.ts @@ -168,7 +168,7 @@ export class FetchRequestAdapter implements RequestAdapter { const rootNode = await this.getRootParseNode(response); const error = rootNode.getObjectValue(factory); - if(error instanceof Error) throw error; + if(error) throw error; else throw new ApiError("unexpected error type" + typeof(error)) } private getHttpResponseMessage = async (requestInfo: RequestInformation): Promise => {