TIL: Popping error stack frames

2021-09-07

If you’re throwing an Error you can set framesToPop to make the trace clearer:

function throwError() {
  const e = new Error();
  e.framesToPop = 1; // skip this frame
  throw e;
}