From 27ad530ac5d737b14afb39cd227c8433a3090910 Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Sun, 24 Sep 2023 13:15:24 -0400 Subject: [PATCH] feat: improve standard error msg --- src/controllers/audit.controller.js | 2 ++ src/controllers/fileStore.controller.js | 7 +++++++ src/controllers/governance.controller.js | 10 ++++++++++ src/controllers/issuance.controller.js | 1 + src/controllers/label.controller.js | 1 + src/controllers/offer.controller.js | 6 ++++++ src/controllers/organization.controller.js | 15 +++++++++++++++ src/controllers/project.controller.js | 8 ++++++++ src/controllers/staging.controller.js | 6 ++++++ src/controllers/units.controller.js | 8 ++++++++ src/middleware.js | 2 ++ 11 files changed, 66 insertions(+) diff --git a/src/controllers/audit.controller.js b/src/controllers/audit.controller.js index 3238edfe..2716df9c 100644 --- a/src/controllers/audit.controller.js +++ b/src/controllers/audit.controller.js @@ -22,6 +22,7 @@ export const findAll = async (req, res) => { res.status(400).json({ message: 'Can not retreive audit data', error: error.message, + success: false, }); } }; @@ -33,6 +34,7 @@ export const findConflicts = async (req, res) => { res.status(400).json({ message: 'Can not retreive audit data', error: error.message, + success: false, }); } }; diff --git a/src/controllers/fileStore.controller.js b/src/controllers/fileStore.controller.js index 3953654d..adb96558 100644 --- a/src/controllers/fileStore.controller.js +++ b/src/controllers/fileStore.controller.js @@ -14,6 +14,7 @@ export const subscribeToFileStore = (req, res) => { res.status(400).json({ message: `Can not subscribe to file store.`, error: error.message, + success: false, }); } }; @@ -31,6 +32,7 @@ export const unsubscribeFromFileStore = (req, res) => { res.status(400).json({ message: 'Can not retrieve file list from filestore', error: error.message, + success: false, }); } }; @@ -43,6 +45,7 @@ export const getFileList = async (req, res) => { res.status(400).json({ message: 'Can not retrieve file list from filestore', error: error.message, + success: false, }); } }; @@ -58,6 +61,7 @@ export const deleteFile = async (req, res) => { res.status(400).json({ message: 'Can not delete file from filestore', error: error.message, + success: false, }); } }; @@ -72,12 +76,14 @@ export const getFile = async (req, res) => { } else { res.status(400).json({ message: `FileId ${fileId} not found in the filestore.`, + success: false, }); } } catch (error) { res.status(400).json({ message: 'Can not retreive file list from filestore', error: error.message, + success: false, }); } }; @@ -112,6 +118,7 @@ export const addFileToFileStore = async (req, res) => { res.status(400).json({ message: 'Can not add file to file store', error: error.message, + success: false, }); } }; diff --git a/src/controllers/governance.controller.js b/src/controllers/governance.controller.js index 397a5a16..0f6c9a97 100644 --- a/src/controllers/governance.controller.js +++ b/src/controllers/governance.controller.js @@ -23,6 +23,7 @@ export const findAll = async (req, res) => { res.status(400).json({ message: 'Can not retreive Governance Data', error: error.message, + success: false, }); } }; @@ -46,6 +47,7 @@ export const isCreated = async (req, res) => { res.status(400).json({ message: 'Can not retreive Governance Data', error: error.message, + success: false, }); } }; @@ -58,6 +60,7 @@ export const findOrgList = async (req, res) => { res.status(400).json({ message: 'Can not retreive Governance Data', error: error.message, + success: false, }); } }; @@ -76,6 +79,7 @@ export const findGlossary = async (req, res) => { res.status(400).json({ message: 'Can not retreive Governance Data', error: error.message, + success: false, }); } }; @@ -95,6 +99,7 @@ export const findPickList = async (req, res) => { res.status(400).json({ message: 'Can not retreive Governance Data', error: error.message, + success: false, }); } }; @@ -116,6 +121,7 @@ export const createGoveranceBody = async (req, res) => { res.status(400).json({ message: 'Cant create Governance Body', error: error.message, + success: false, }); } }; @@ -141,6 +147,7 @@ export const setDefaultOrgList = async (req, res) => { res.status(400).json({ message: 'Cant update default orgs', error: error.message, + success: false, }); } }; @@ -165,6 +172,7 @@ export const setPickList = async (req, res) => { res.status(400).json({ message: 'Cant update picklist', error: error.message, + success: false, }); } }; @@ -188,6 +196,7 @@ export const setGlossary = async (req, res) => { res.status(400).json({ message: 'Cant update glossary', error: error.message, + success: false, }); } }; @@ -202,6 +211,7 @@ export const sync = async (req, res) => { res.status(400).json({ message: 'Cant Sync Governance Body', error: error.message, + success: false, }); } }; diff --git a/src/controllers/issuance.controller.js b/src/controllers/issuance.controller.js index bc2d03f4..e7e889bb 100644 --- a/src/controllers/issuance.controller.js +++ b/src/controllers/issuance.controller.js @@ -16,6 +16,7 @@ export const findAll = async (req, res) => { res.status(400).json({ message: 'Can not retreive issuances', error: error.message, + success: false, }); } }; diff --git a/src/controllers/label.controller.js b/src/controllers/label.controller.js index e400893a..8ad8ea50 100644 --- a/src/controllers/label.controller.js +++ b/src/controllers/label.controller.js @@ -16,6 +16,7 @@ export const findAll = async (req, res) => { res.status(400).json({ message: 'Can not retreive labels', error: error.message, + success: false, }); } }; diff --git a/src/controllers/offer.controller.js b/src/controllers/offer.controller.js index 487e7f31..de2acbaa 100644 --- a/src/controllers/offer.controller.js +++ b/src/controllers/offer.controller.js @@ -35,6 +35,7 @@ export const generateOfferFile = async (req, res) => { res.status(400).json({ message: 'Error generating offer file.', error: error.message, + success: false, }); } }; @@ -67,6 +68,7 @@ export const cancelActiveOffer = async (req, res) => { res.status(400).json({ message: 'Can not cancel active offer', error: error.message, + success: false, }); } }; @@ -106,6 +108,7 @@ export const importOfferFile = async (req, res) => { res.status(400).json({ message: 'Can not import offer file.', error: error.message, + success: false, }); } }; @@ -140,6 +143,7 @@ export const commitImportedOfferFile = async (req, res) => { res.status(400).json({ message: 'Can not commit offer.', error: error.message, + success: false, }); } }; @@ -157,6 +161,7 @@ export const cancelImportedOfferFile = async (req, res) => { res.status(400).json({ message: 'Can not cancel offer.', error: error.message, + success: false, }); } }; @@ -231,6 +236,7 @@ export const getCurrentOfferInfo = async (req, res) => { res.status(400).json({ message: 'Can not get offer.', error: error.message, + success: false, }); } }; diff --git a/src/controllers/organization.controller.js b/src/controllers/organization.controller.js index 920e3120..a0da50e4 100644 --- a/src/controllers/organization.controller.js +++ b/src/controllers/organization.controller.js @@ -44,6 +44,7 @@ export const editHomeOrg = async (req, res) => { res.status(400).json({ message: 'Error initiating your organization', error: error.message, + success: false, }); } }; @@ -86,6 +87,7 @@ export const createV2 = async (req, res) => { res.status(400).json({ message: 'Error initiating your organization', error: error.message, + success: false, }); } }; @@ -119,6 +121,7 @@ export const create = async (req, res) => { res.status(400).json({ message: 'Error initiating your organization', error: error.message, + success: false, }); } }; @@ -143,6 +146,7 @@ export const resetHomeOrg = async (req, res) => { res.status(400).json({ message: 'Error resetting your organization', error: error.message, + success: false, }); } }; @@ -165,6 +169,7 @@ export const importOrg = async (req, res) => { res.status(400).json({ message: 'Error importing organization', error: error.message, + success: false, }); } }; @@ -186,6 +191,7 @@ export const importHomeOrg = async (req, res) => { res.status(400).json({ message: 'Error importing organization', error: error.message, + success: false, }); } }; @@ -205,6 +211,7 @@ export const subscribeToOrganization = async (req, res) => { res.status(400).json({ message: 'Error subscribing to organization', error: error.message, + success: false, }); } }; @@ -239,6 +246,7 @@ export const deleteImportedOrg = async (req, res) => { res.status(400).json({ message: 'Error unsubscribing to organization', error: error.message, + success: false, }); if (transaction) { await transaction.rollback(); @@ -278,6 +286,7 @@ export const unsubscribeToOrganization = async (req, res) => { res.status(400).json({ message: 'Error unsubscribing to organization', error: error.message, + success: false, }); if (transaction) { @@ -317,6 +326,7 @@ export const resyncOrganization = async (req, res) => { res.status(400).json({ message: 'Error resyncing organization', error: error.message, + success: false, }); if (transaction) { @@ -341,6 +351,7 @@ export const addMetadata = async (req, res) => { res.status(400).json({ message: 'Error adding metadata to your organization', error: error.message, + success: false, }); } }; @@ -359,6 +370,7 @@ export const addMirror = async (req, res) => { res.status(400).json({ message: 'Error adding mirror', error: error.message, + success: false, }); } }; @@ -376,6 +388,7 @@ export const getMetaData = async (req, res) => { res.status(400).json({ message: 'Error getting metadata for organization', error: error.message, + success: false, }); } }; @@ -393,6 +406,7 @@ export const removeMirror = async (req, res) => { } catch (error) { res.status(400).json({ message: 'Error removing mirror for organization', + success: false, }); } }; @@ -407,6 +421,7 @@ export const sync = async (req, res) => { res.status(400).json({ message: 'Cant All Organizations Metadata', error: error.message, + success: false, }); } }; diff --git a/src/controllers/project.controller.js b/src/controllers/project.controller.js index 28f577b2..431e4118 100644 --- a/src/controllers/project.controller.js +++ b/src/controllers/project.controller.js @@ -109,6 +109,7 @@ export const create = async (req, res) => { res.status(400).json({ message: 'Error creating new project', error: err.message, + success: false, }); } }; @@ -248,6 +249,7 @@ export const findAll = async (req, res) => { res.status(400).json({ message: 'Error retrieving projects', error: error.message, + success: false, }); } }; @@ -266,6 +268,7 @@ export const findOne = async (req, res) => { res.status(400).json({ message: 'Error retrieving projects', error: error.message, + success: false, }); } }; @@ -294,6 +297,7 @@ export const updateFromXLS = async (req, res) => { res.status(400).json({ message: 'Batch Upload Failed.', error: error.message, + success: false, }); } }; @@ -305,6 +309,7 @@ export const transfer = async (req, res) => { } catch (err) { res.status(400).json({ message: err.message, + success: false, }); logger.error('Error adding update to stage', err); } @@ -404,6 +409,7 @@ const update = async (req, res, isTransfer = false) => { } catch (err) { res.status(400).json({ message: err.message, + success: false, }); logger.error('Error adding update to stage', err); } @@ -438,6 +444,7 @@ export const destroy = async (req, res) => { res.status(400).json({ message: 'Error adding project removal to stage', error: err.message, + success: false, }); } }; @@ -460,6 +467,7 @@ export const batchUpload = async (req, res) => { res.status(400).json({ message: 'Batch Upload Failed.', error: error.message, + success: false, }); } }; diff --git a/src/controllers/staging.controller.js b/src/controllers/staging.controller.js index fa764593..51bee162 100644 --- a/src/controllers/staging.controller.js +++ b/src/controllers/staging.controller.js @@ -82,6 +82,7 @@ export const findAll = async (req, res) => { res.status(400).json({ message: 'Error retreiving staging table', error: error.message, + success: false, }); } }; @@ -107,6 +108,7 @@ export const commit = async (req, res) => { res.status(400).json({ message: 'Error commiting staging table', error: error.message, + success: false, }); } }; @@ -128,6 +130,7 @@ export const destroy = async (req, res) => { res.status(400).json({ message: 'Staging Record can not be removed.', error: error.message, + success: false, }); } }; @@ -146,6 +149,7 @@ export const clean = async (req, res) => { } catch (error) { res.status(400).json({ message: error.message, + success: false, }); } }; @@ -168,6 +172,7 @@ export const editRecord = async (req, res) => { res.status(400).json({ message: 'Staging Record can not be edited.', error: error.message, + success: false, }); } }; @@ -193,6 +198,7 @@ export const retryRecrod = async (req, res) => { res.status(400).json({ message: 'Staging Record can not be restaged.', error: error.message, + success: false, }); } }; diff --git a/src/controllers/units.controller.js b/src/controllers/units.controller.js index 3d103ba0..f6468172 100644 --- a/src/controllers/units.controller.js +++ b/src/controllers/units.controller.js @@ -113,6 +113,7 @@ export const create = async (req, res) => { res.status(400).json({ message: 'Unit Insert Failed to stage.', error: error.message, + success: false, }); } }; @@ -269,6 +270,7 @@ export const findAll = async (req, res) => { res.status(400).json({ message: 'Error retrieving units', error: error.message, + success: false, }); } }; @@ -293,6 +295,7 @@ export const findOne = async (req, res) => { res.status(400).json({ message: 'Cant find Unit.', error: error.message, + success: false, }); } }; @@ -321,6 +324,7 @@ export const updateFromXLS = async (req, res) => { res.status(400).json({ message: 'Batch Upload Failed.', error: error.message, + success: false, }); } }; @@ -407,6 +411,7 @@ export const update = async (req, res) => { res.status(400).json({ message: 'Error updating new unit', error: err.message, + success: false, }); } }; @@ -437,6 +442,7 @@ export const destroy = async (req, res) => { res.status(400).json({ message: 'Error deleting new unit', error: err.message, + success: false, }); } }; @@ -523,6 +529,7 @@ export const split = async (req, res) => { res.status(400).json({ message: 'Error splitting unit', error: error.message, + success: false, }); } }; @@ -545,6 +552,7 @@ export const batchUpload = async (req, res) => { res.status(400).json({ message: 'Batch Upload Failed.', error: error.message, + success: false, }); } }; diff --git a/src/middleware.js b/src/middleware.js index b0cc95f8..b77a3833 100644 --- a/src/middleware.js +++ b/src/middleware.js @@ -48,6 +48,7 @@ app.use(async function (req, res, next) { res.status(400).json({ message: 'Chia Exception', error: err.message, + success: false, }); } }); @@ -120,6 +121,7 @@ app.use((err, req, res, next) => { errors: err.error.details.map((detail) => { return _.get(detail, 'context.message', detail.message); }), + success: false, }); }