From cdddae09086e38407465d51110bfddd31d30f062 Mon Sep 17 00:00:00 2001 From: Inian Parameshwaran Date: Thu, 18 Mar 2021 12:26:52 +0530 Subject: [PATCH] fix: handle jwt error in createObject --- src/routes/object/createObject.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/routes/object/createObject.ts b/src/routes/object/createObject.ts index 502e4dcd..f8342e33 100644 --- a/src/routes/object/createObject.ts +++ b/src/routes/object/createObject.ts @@ -56,7 +56,17 @@ export default async function routes(fastify: FastifyInstance) { const objectName = request.params['*'] const postgrest = getPostgrestClient(jwt) - const owner = await getOwner(jwt) + let owner + try { + owner = await getOwner(jwt) + } catch (err) { + console.log(err) + return response.status(400).send({ + statusCode: '400', + error: err.message, + message: err.message, + }) + } // @todo how to merge these into one query? // i can create a view and add INSTEAD OF triggers..is that the way to do it? const bucketResponse = await postgrest