a
This commit is contained in:
13
consumerWebsite/utils/error.js
Normal file
13
consumerWebsite/utils/error.js
Normal file
@ -0,0 +1,13 @@
|
||||
class AppError extends Error {
|
||||
constructor(msg, statusCode) {
|
||||
super(msg);
|
||||
|
||||
this.statusCode = statusCode;
|
||||
this.error = `${statusCode}`.startsWith('4') ? 'fail' : 'error';
|
||||
this.isOperational = true;
|
||||
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = AppError;
|
0
consumerWebsite/utils/errorHandler.js
Normal file
0
consumerWebsite/utils/errorHandler.js
Normal file
8
consumerWebsite/utils/object_isEmpty.js
Normal file
8
consumerWebsite/utils/object_isEmpty.js
Normal file
@ -0,0 +1,8 @@
|
||||
//Checking that the request body is empty
|
||||
exports.isEmpty = function (obj) {
|
||||
for(var prop in obj) {
|
||||
if(obj.hasOwnProperty(prop))
|
||||
return false;
|
||||
}
|
||||
return JSON.stringify(obj) === JSON.stringify({});
|
||||
}
|
Reference in New Issue
Block a user