andywer / leakage

🐛 Memory leak testing for node.
1.58k stars 52 forks source link

Custom Error #10

Closed mastilver closed 7 years ago

mastilver commented 7 years ago

this https://github.com/andywer/leakage/blob/master/lib/leakErrorFactory.js#L26 should use a custom error

The custom Error should be exported as well so we can do that:

import { iterate, LeakageError } from 'leakage';

try {
  iterate(100, () => {
    throw new Error('random error')
  })
} catch (err) {
  if (err instanceof LeakageError) {
    // leaked detected
  }

  // something else happened
}

I use LeakageError but we need to find a better name ;)

andywer commented 7 years ago

Sure :) How about LeakError?

Btw: What's the use case for deciding if it is a memory leak error or something else?

mastilver commented 7 years ago

@andywer Thank you so much for looking into that

Sorry I wasn't much active on the Promise /async work, you did some awesome work there!! 👍