Skip to content

Commit

Permalink
Make OAuthError extend GenericError
Browse files Browse the repository at this point in the history
  • Loading branch information
frederikprijck committed Oct 31, 2023
1 parent 30e1707 commit 54ecb55
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/errors.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
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 Error {
constructor(public error: string, public error_description?: string) {
super(error_description || error);
export class OAuthError extends GenericError {
constructor(public error: string, public error_description: string = '') {
super(error, 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);
Expand Down

0 comments on commit 54ecb55

Please sign in to comment.