{"size": 584, "ext": "js", "max_stars_repo_path": "src/modular/internal/trycatchutils.js", "max_stars_repo_name": "plemarquand/RxJS", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/modular/internal/trycatchutils.js", "max_issues_repo_name": "plemarquand/RxJS", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/modular/internal/trycatchutils.js", "max_forks_repo_name": "plemarquand/RxJS", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 18.25, "max_line_length": 72, "alphanum_fraction": 0.6369863014}
'use strict';

var isFunction = require('../helpers/isfunction');

global.Rx || (global.Rx = {});
var errorObj = global.Rx.errorObj = {e: {}};

function tryCatcherGen(tryCatchTarget) {
  return function tryCatcher() {
    try {
      return tryCatchTarget.apply(this, arguments);
    } catch (e) {
      errorObj.e = e;
      return errorObj;
    }
  };
}

function tryCatch(fn) {
  if (!isFunction(fn)) { throw new TypeError('fn must be a function'); }
  return tryCatcherGen(fn);
}

function thrower(e) {
  throw e;
}

module.exports = {
  tryCatch: tryCatch,
  thrower: thrower
};
