From 9cde77427354eed2deac5d2eb295aa7e61f18f4a Mon Sep 17 00:00:00 2001 From: tdurieux Date: Thu, 16 Feb 2023 07:56:50 +0100 Subject: [PATCH] fix: improve error handling when users conntect --- src/routes/connection.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/routes/connection.ts b/src/routes/connection.ts index 9a7ddb3..abf366c 100644 --- a/src/routes/connection.ts +++ b/src/routes/connection.ts @@ -9,6 +9,7 @@ import * as express from "express"; import config from "../../config"; import UserModel from "../database/users/users.model"; import { IUserDocument } from "../database/users/users.types"; +import AnonymousError from "../AnonymousError"; export function ensureAuthenticated( req: express.Request, @@ -52,6 +53,11 @@ const verify = async ( await user.save(); } catch (error) { console.error(error); + throw new AnonymousError("unable_to_connect_user", { + httpStatus: 500, + object: profile, + cause: error as Error, + }); } finally { done(null, { username: profile.username,