hiteshchoudhary / chai-backend

A video series on chai aur code youtube channel
5.36k stars 802 forks source link

ApiError class: Issue with message property #147

Open Amanp30 opened 4 months ago

Amanp30 commented 4 months ago

Don't pass message to super and not comment this.message = message line. This class returning object with message

class ApiError extends Error { constructor( statusCode, message = "Something went wrong", errors = [], stack = "" ) { super(); this.statusCode = statusCode; this.data = null; this.message = message; this.success = false; this.errors = errors;

if (stack) {
  this.stack = stack;
} else {
  Error.captureStackTrace(this, this.constructor);
}

} }

module.exports = ApiError;