From d7f5840fa46383df90b51f4b82f5d123d570b65f Mon Sep 17 00:00:00 2001 From: William Oldham Date: Wed, 16 Oct 2024 14:09:23 +0100 Subject: [PATCH] Use appropriate error message and status code for register route --- src/services/api/routes/v1/register.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/services/api/routes/v1/register.ts b/src/services/api/routes/v1/register.ts index 2b1928b..728b8f8 100644 --- a/src/services/api/routes/v1/register.ts +++ b/src/services/api/routes/v1/register.ts @@ -345,15 +345,16 @@ router.post('/', async (request: express.Request, response: express.Response): P await pnid.save({ session }); await session.commitTransaction(); - } catch (error) { + } catch (error: any) { LOG_ERROR('[POST] /v1/register: ' + error); + if (error.stack) console.error(error.stack) await session.abortTransaction(); - response.status(400).json({ + response.status(500).json({ app: 'api', - status: 400, - error: 'Password must have combination of letters, numbers, and/or punctuation characters' + status: 500, + error: 'Internal server error' }); return;