Skip to content

Commit 3d0f19e

Browse files
chore: remove unnecessary error logs (#2179)
Co-authored-by: Frederik Prijck <frederik.prijck@auth0.com>
1 parent 0139fea commit 3d0f19e

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/errors/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,13 @@ export enum AccessTokenErrorCode {
103103

104104
export class AccessTokenError extends SdkError {
105105
public code: string;
106+
public cause?: OAuth2Error;
106107

107-
constructor(code: string, message: string) {
108+
constructor(code: string, message: string, cause?: OAuth2Error) {
108109
super(message);
109110
this.name = "AccessTokenError";
110111
this.code = code;
112+
this.cause = cause;
111113
}
112114
}
113115

src/server/auth-client.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ import { AbstractSessionStore } from "./session/abstract-session-store.js";
3939
import { TransactionState, TransactionStore } from "./transaction-store.js";
4040
import { filterDefaultIdTokenClaims } from "./user.js";
4141

42-
4342
export type BeforeSessionSavedHook = (
4443
session: SessionData,
4544
idToken: string | null
@@ -733,7 +732,6 @@ export class AuthClient {
733732
await this.discoverAuthorizationServerMetadata();
734733

735734
if (discoveryError) {
736-
console.error(discoveryError);
737735
return [discoveryError, null];
738736
}
739737

@@ -757,11 +755,14 @@ export class AuthClient {
757755
refreshTokenRes
758756
);
759757
} catch (e: any) {
760-
console.error(e);
761758
return [
762759
new AccessTokenError(
763760
AccessTokenErrorCode.FAILED_TO_REFRESH_TOKEN,
764-
"The access token has expired and there was an error while trying to refresh it. Check the server logs for more information."
761+
"The access token has expired and there was an error while trying to refresh it.",
762+
new OAuth2Error({
763+
code: e.error,
764+
message: e.error_description
765+
})
765766
),
766767
null
767768
];
@@ -815,7 +816,7 @@ export class AuthClient {
815816
return [null, authorizationServerMetadata];
816817
} catch (e) {
817818
console.error(
818-
`An error occured while performing the discovery request. Please make sure the AUTH0_DOMAIN environment variable is correctly configured — the format must be 'example.us.auth0.com'. issuer=${issuer.toString()}, error:`,
819+
`An error occured while performing the discovery request. issuer=${issuer.toString()}, error:`,
819820
e
820821
);
821822
return [
@@ -1106,7 +1107,6 @@ export class AuthClient {
11061107
await this.discoverAuthorizationServerMetadata();
11071108

11081109
if (discoveryError) {
1109-
console.error(discoveryError);
11101110
return [discoveryError, null];
11111111
}
11121112

@@ -1130,11 +1130,10 @@ export class AuthClient {
11301130
httpResponse
11311131
);
11321132
} catch (err: any) {
1133-
console.error(err);
11341133
return [
11351134
new AccessTokenForConnectionError(
11361135
AccessTokenForConnectionErrorCode.FAILED_TO_EXCHANGE,
1137-
"There was an error trying to exchange the refresh token for a connection access token. Check the server logs for more information.",
1136+
"There was an error trying to exchange the refresh token for a connection access token.",
11381137
new OAuth2Error({
11391138
code: err.error,
11401139
message: err.error_description

0 commit comments

Comments
 (0)