Skip to content

Commit

Permalink
Change error handling to not show flow disruption errors (supabase#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
silentworks authored Jul 16, 2022
1 parent beaae7d commit 8e0b747
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 16 deletions.
6 changes: 6 additions & 0 deletions .changeset/shaggy-jokes-remember.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@supabase/auth-helpers-nextjs': patch
'@supabase/auth-helpers-sveltekit': patch
---

Change error handling to not show flow disruption errors
5 changes: 1 addition & 4 deletions packages/nextjs/src/handlers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,8 @@ export default async function handleUser(
if (e instanceof JWTPayloadFailed) {
logger.info('JWTPayloadFailed error has happened!');
response.error = e.toObj();
} else if (e instanceof CookieNotFound) {
logger.warn(e.toString());
} else if (e instanceof AuthHelperError) {
logger.info('AuthHelperError error has happened!');
logger.error(e.toString());
// do nothing because since this just means the user isn't logged in
} else {
const error = e as ApiError;
logger.error(error.message);
Expand Down
5 changes: 1 addition & 4 deletions packages/nextjs/src/utils/getUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,8 @@ export default async function getUser(
if (e instanceof JWTPayloadFailed) {
logger.info('JWTPayloadFailed error has happened!');
response.error = e.toObj();
} else if (e instanceof CookieNotFound) {
logger.warn(e.toString());
} else if (e instanceof AuthHelperError) {
logger.info('AuthHelperError error has happened!');
logger.error(e.toString());
// do nothing, these are all just to disrupt the control flow
} else {
const error = e as ApiError;
logger.error(error.message);
Expand Down
5 changes: 1 addition & 4 deletions packages/sveltekit/src/handlers/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,8 @@ export const handleSession = (options: HandleUserOptions = {}) => {
if (e instanceof JWTPayloadFailed) {
logger.info('JWTPayloadFailed error has happened!');
event.locals.error = e.toObj();
} else if (e instanceof CookieNotFound) {
logger.warn(e.toString());
} else if (e instanceof AuthHelperError) {
logger.info('AuthHelperError error has happened!');
logger.error(e.toString());
// do nothing, these are all just to disrupt the control flow
} else {
const error = e as ApiError;
logger.error(error.message);
Expand Down
5 changes: 1 addition & 4 deletions packages/sveltekit/src/utils/getUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,8 @@ export async function getUser(
if (e instanceof JWTPayloadFailed) {
logger.info('JWTPayloadFailed error has happened!');
response.error = e.toObj();
} else if (e instanceof CookieNotFound) {
logger.warn(e.toString());
} else if (e instanceof AuthHelperError) {
logger.info('AuthHelperError error has happened!');
logger.error(e.toString());
// do nothing, these are all just to disrupt the control flow
} else {
const error = e as ApiError;
logger.error(error.message);
Expand Down

0 comments on commit 8e0b747

Please sign in to comment.