From 0224e29d39b791ed608726b1cecab2f231de40a5 Mon Sep 17 00:00:00 2001 From: Zak Faithfull Date: Wed, 12 Feb 2025 11:10:55 +0000 Subject: [PATCH] handle errors gracefully --- server/routes/applications/viewApplicationsRoutes.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/server/routes/applications/viewApplicationsRoutes.ts b/server/routes/applications/viewApplicationsRoutes.ts index ded68e8..2dd9f2b 100644 --- a/server/routes/applications/viewApplicationsRoutes.ts +++ b/server/routes/applications/viewApplicationsRoutes.ts @@ -1,5 +1,4 @@ import { Request, Response, Router } from 'express' - import { APPLICATION_TYPES } from '../../constants/applicationTypes' import asyncMiddleware from '../../middleware/asyncMiddleware' import AuditService, { Page } from '../../services/auditService' @@ -19,7 +18,7 @@ export default function viewApplicationRoutes({ auditService }: { auditService: } if (!application) { - res.status(404).send('Application not found') + res.redirect('/applications') return } @@ -31,7 +30,7 @@ export default function viewApplicationRoutes({ auditService }: { auditService: const applicationType = APPLICATION_TYPES.find(type => type.value === application.type) if (!applicationType) { - res.status(400).send('Invalid application type') + res.redirect('/applications?error=unknown-type') return }