logo

tne

The tne function stands for throw new error. It takes a message and options and throws a new error.

import { tne } from '@aracna/core';

function divide(a, b) {
  if (b === 0) {
    tne('cannot divide by zero');
  }

  return a / b;
}

// will log 5
console.log(divide(3, 2));

// will throw Error: Cannot divide by zero
console.log(divide(1, 0));