From 0c1ea7fa0f58b02a01a99af59c6298bd2da46ee4 Mon Sep 17 00:00:00 2001 From: Daniel Mouris Date: Mon, 6 May 2024 08:39:08 -0600 Subject: [PATCH] Fixed error handling --- server/api/events.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/server/api/events.js b/server/api/events.js index 57ce85e..d73ecf3 100644 --- a/server/api/events.js +++ b/server/api/events.js @@ -87,11 +87,12 @@ export default defineEventHandler(async (event) => { serviceAccountCredentials = JSON.parse(serviceAccountCredentialsJSON) } catch { - return { + throw createError({ statusCode: 400, + statusMessage: 'Bad Request', message: 'No Service Account Credentials Provided', error: 'Service Account Credentials are not provided', - } + }) } try { @@ -109,11 +110,11 @@ export default defineEventHandler(async (event) => { events, } } - catch (error) { - return { + catch { + throw createError({ statusCode: 400, - message: 'Bad Request', - error: error.message, - } + statusMessage: 'Bad Request', + message: 'Invalid Request to the Calendar API', + }) } })