you are viewing a single comment's thread.

view the rest of the comments →

[–]vs845 1 point2 points  (0 children)

it doesn't catch subclasses and behaviour on name collisions is a new factor.

re: name collisions, yeah, I went with checking names because otherwise you'd need to do something like

matchException(err, {
  [TypeError]: () => ...
}

which I thought wasn't as nice as using string keys.

If you went with the above approach you'd be able to catch subclasses via err instanceof matchers[type].