Skip to content

Commit

Permalink
Fixed error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dgmouris committed May 6, 2024
1 parent c0e24d7 commit 0c1ea7f
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions server/api/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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',
})
}
})

0 comments on commit 0c1ea7f

Please sign in to comment.