'use strict';



function purry_error(factory){
  function do_purry_error(){
    var err = factory.apply(null, arguments);
    Error.captureStackTrace(err, do_purry_error);
    remove_purry_wrapper_trace(err);
    return err;
  }
  return do_purry_error;
}

function remove_purry_wrapper_trace(err){
  err.stack = err.stack.split('\n').filter(function(x){
    return !~x.indexOf('purry_wrapper');
  }).join('\n');
  return err;
}



module.exports = purry_error;
'use strict';



function purry_error(factory){
  function do_purry_error(){
    var err = factory.apply(null, arguments);
    Error.captureStackTrace(err, do_purry_error);
    removeStackCallsite(err, 'purry_wrapper');
    return err;
  }
  return do_purry_error;
}

/*
Remove a stack trace
*/
function removeStackCallsite(err, str_to_match){
  err.stack = err.stack
    .split('\n')
    .filter(function(frame_str){ return !~frame_str.indexOf(str_to_match); })
    .join('\n');
  return err;
}



module.exports = purry_error;
refactor purry-error