diff --git a/lib/helpers/errors.js b/lib/helpers/errors.js index a932eedb..047b35e3 100644 --- a/lib/helpers/errors.js +++ b/lib/helpers/errors.js @@ -5,21 +5,11 @@ const path = require('path'); const config = require(path.resolve('./config')); -// const AppError = require(path.resolve('./lib/helpers/AppError')); - /** - * Error Handling - */ -// exports.throwError = (code, errorType, errorMessage) => (error) => { -// if (!error) error = new AppError(errorMessage || 'Default Error'); -// error.code = code; -// error.errorType = errorType; -// throw error; -// }; - -/** - * errors messages generation + * @desc Function to parse error message + * @param {Object} err + * @return {String} message */ const getUniqueMessage = (err) => { let output; @@ -44,6 +34,11 @@ const getUniqueMessage = (err) => { return output; }; +/** + * @desc Function to get error message from specific code + * @param {Object} err + * @return {String} message + */ const getMessageFromCode = (err) => { let output; switch (err.code) { @@ -66,6 +61,11 @@ const getMessageFromCode = (err) => { return output; }; +/** + * @desc Function to map an array of errors + * @param {Object} err + * @return {String} message + */ const getError = (err) => { if (err instanceof Array) return err.errors; let output = ''; @@ -78,6 +78,11 @@ const getError = (err) => { return output; }; +/** + * @desc Function to route error to specific actio in order to get clean result for api + * @param {Object} err + * @return {String} message + */ exports.getMessage = (err) => { let output = ''; if (err.code) output = getMessageFromCode(err); diff --git a/lib/helpers/responses.js b/lib/helpers/responses.js index 2b1b6b80..a9239f15 100644 --- a/lib/helpers/responses.js +++ b/lib/helpers/responses.js @@ -1,7 +1,3 @@ -/** - * Defaults answers - */ - /** * @desc Function res success * @param {Object} res - Express response object