setTimeout(function() {
  try {
    noSuchVariable; // try..catch handles the error!
  } catch (error) {
    console.log(error);
  } finally {
		// Execute always ...
	}
}, 1000);

Error Object

Throwing Custom Errors

let error = new Error(message);
let error = new SyntaxError(message);
let error = new ReferenceError(message);

throw error;
throw new Error(message);

Extending Error

class Error {
  constructor(message) {
    this.message = message;
		// (different names for different built-in error classes)
    this.name = "Error";
  }
}

class ValidationError extends Error {
  constructor(message) {
    super(message); // (1)
    this.name = "ValidationError";
  }
}