logo

rne

The rne function stands for return new error. It takes a message and options and returns a new error.

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

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

  return a / b;
}

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

// will log Error
console.log(divide(1, 0));