Javascript: How to Make Custom Errors

Rating: 4

You can make custom errors by extending from the base Error class.

Example

class CustomError extends Error {
  constructor(message, originalError) {
    super(message);
    this.originalError = originalError;
  }
}