From 4e5ae9aaabd981fac103846b0f92dd4c5eb8e363 Mon Sep 17 00:00:00 2001 From: Jesse Shieh Date: Sun, 7 Jun 2020 19:58:50 -0700 Subject: [PATCH 1/2] Set HttpError name to be HttpError --- packages/ra-core/src/dataProvider/HttpError.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ra-core/src/dataProvider/HttpError.ts b/packages/ra-core/src/dataProvider/HttpError.ts index c0caa23bc52..0ce4ea8cc13 100644 --- a/packages/ra-core/src/dataProvider/HttpError.ts +++ b/packages/ra-core/src/dataProvider/HttpError.ts @@ -5,7 +5,7 @@ class HttpError extends Error { public readonly body = null ) { super(message); - this.name = this.constructor.name; + this.name = 'HttpError'; if (typeof Error.captureStackTrace === 'function') { Error.captureStackTrace(this, this.constructor); } else { From fbb5b3b14c1652076a97e2283cfa345369e1983e Mon Sep 17 00:00:00 2001 From: Jesse Shieh Date: Mon, 8 Jun 2020 00:31:32 -0700 Subject: [PATCH 2/2] Set prototype instead of setting nameexplicitly --- packages/ra-core/src/dataProvider/HttpError.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/ra-core/src/dataProvider/HttpError.ts b/packages/ra-core/src/dataProvider/HttpError.ts index 0ce4ea8cc13..fa01d3c79b8 100644 --- a/packages/ra-core/src/dataProvider/HttpError.ts +++ b/packages/ra-core/src/dataProvider/HttpError.ts @@ -5,7 +5,8 @@ class HttpError extends Error { public readonly body = null ) { super(message); - this.name = 'HttpError'; + Object.setPrototypeOf(this, HttpError.prototype); + this.name = this.constructor.name; if (typeof Error.captureStackTrace === 'function') { Error.captureStackTrace(this, this.constructor); } else {