code: function getNamedError(obj) {
    if (obj && obj instanceof Error && 'name' in obj) {
      var Constructor = exports[obj.name];
      if (typeof Constructor === 'function') {
        var res = new Constructor(obj.message);
        if (res) {
          res.stack = obj.stack;
          return res;
        }
      }
    }
    return obj;
  }
docs: Generic helper method to map a named Error object into the correct
  sub-type so that instanceof checking works as expected.
  
  @param {Object}
  obj - the Error object to remap.
  @return {Object} a sub-typed Error object.