1. Home
  2. Nodejs Boilerplate
  3. প্রজেক্ট তৈরী ও কনফিগ করা
  4. ৭। কাস্টম Error ক্লাস

৭। কাস্টম Error ক্লাস

//utils/ApiError.js
class ApiError extends Error {
    constructor(statusCode, message, isOperational = true, stack = "") {
      super(message);
      this.statusCode = statusCode;
      this.isOperational = isOperational;
      if (stack) {
        this.stack = stack;
      } else {
        Error.captureStackTrace(this, this.constructor);
      }
    }
  }
  
  module.exports = ApiError;

How can we help?