From ce14fdfd219277482485ba0168e5a32fccdbbe5a Mon Sep 17 00:00:00 2001 From: Frederik Prijck Date: Thu, 2 Nov 2023 08:56:43 +0100 Subject: [PATCH] Revert "Make OAuthError extend GenericError (#638)" This reverts commit 9079a32c8576c49da5bfce0472844e1dc8be0c0f. --- __mocks__/@auth0/auth0-spa-js.tsx | 7 ------- src/errors.tsx | 8 +++----- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/__mocks__/@auth0/auth0-spa-js.tsx b/__mocks__/@auth0/auth0-spa-js.tsx index 735cd52a..b19548ad 100644 --- a/__mocks__/@auth0/auth0-spa-js.tsx +++ b/__mocks__/@auth0/auth0-spa-js.tsx @@ -27,10 +27,3 @@ export const Auth0Client = jest.fn(() => { logout, }; }); - -export class GenericError extends Error { - constructor(public error: string, public error_description: string) { - super(error_description); - Object.setPrototypeOf(this, GenericError.prototype); - } -} diff --git a/src/errors.tsx b/src/errors.tsx index e9dcf22d..fc8a62d7 100644 --- a/src/errors.tsx +++ b/src/errors.tsx @@ -1,14 +1,12 @@ -import { GenericError } from "@auth0/auth0-spa-js"; - /** * An OAuth2 error will come from the authorization server and will have at least an `error` property which will * be the error code. And possibly an `error_description` property * * See: https://openid.net/specs/openid-connect-core-1_0.html#rfc.section.3.1.2.6 */ -export class OAuthError extends GenericError { - constructor(error: string, error_description?: string) { - super(error, error_description || error); +export class OAuthError extends Error { + constructor(public error: string, public error_description?: string) { + super(error_description || error); // https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work Object.setPrototypeOf(this, OAuthError.prototype);