function objectToError (obj) {
  var temp = new Error('')
  var props = Object.keys(obj)

  for (var i = 0; i < props.length; i++) {
    temp[props[i]] = obj[props[i]]
  }

  return temp
}
Converts a serialized error to Error
@param {Object} obj Error that has been serialized and parsed to object
@return {Error} The equivalent Error.