From 4e80443bd35585e1fa92983fde37a6164adc3d30 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 27 Dec 2022 14:37:25 +0530 Subject: [PATCH] refactor: on list/read api error return status 500 Signed-off-by: Pranav C --- .../nocodb/src/lib/meta/api/dataApis/dataAliasApis.ts | 11 +++++++---- packages/nocodb/src/lib/meta/api/dataApis/dataApis.ts | 8 +++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/nocodb/src/lib/meta/api/dataApis/dataAliasApis.ts b/packages/nocodb/src/lib/meta/api/dataApis/dataAliasApis.ts index 82658b312c..e3a340268b 100644 --- a/packages/nocodb/src/lib/meta/api/dataApis/dataAliasApis.ts +++ b/packages/nocodb/src/lib/meta/api/dataApis/dataAliasApis.ts @@ -124,8 +124,10 @@ async function getDataList(model, view: View, req) { ); count = await baseModel.count(listArgs); } catch (e) { - // show empty result instead of throwing error here - // e.g. search some text in a numeric field + console.log(e); + NcError.internalServerError( + 'Internal Server Error, check server log for more details' + ); } return new PagedResponseImpl(data, { @@ -281,8 +283,9 @@ async function getGroupedDataList(model, view: View, req) { }); } catch (e) { console.log(e); - // show empty result instead of throwing error here - // e.g. search some text in a numeric field + NcError.internalServerError( + 'Internal Server Error, check server log for more details' + ); } return data; } diff --git a/packages/nocodb/src/lib/meta/api/dataApis/dataApis.ts b/packages/nocodb/src/lib/meta/api/dataApis/dataApis.ts index a896ae2a99..b8a8899b5f 100644 --- a/packages/nocodb/src/lib/meta/api/dataApis/dataApis.ts +++ b/packages/nocodb/src/lib/meta/api/dataApis/dataApis.ts @@ -328,7 +328,9 @@ async function dataRead(req: Request, res: Response, next) { ); } catch (e) { console.log(e); - res.status(500).json({ msg: e.message }); + NcError.internalServerError( + 'Internal Server Error, check server log for more details' + ); } } @@ -465,6 +467,10 @@ async function getDataList(model, view: View, req) { } catch (e) { // show empty result instead of throwing error here // e.g. search some text in a numeric field + console.log(e); + NcError.internalServerError( + 'Internal Server Error, check server log for more details' + ); } return new PagedResponseImpl(data, {