import { takeEvery } from 'redux-saga';
import { call, put } from 'redux-saga/effects';


export default function sagasBuilder(request, REQUEST, actions) {
  function* makeRequest({ payload, meta }) {
    let data;
    let error;

    try {
      yield put(actions.pending());
      data = yield call(request, payload, meta);
      yield put(actions.success(data));
    } catch (err) {
      error = err;
      yield put(actions.failure(error));
    }

    return {
      data,
      error,
    };
  }

  function* watchForRequest() {
    yield takeEvery(REQUEST, makeRequest);
  }

  return {
    makeRequest,
    watchForRequest,
  };
}

@@ -145,16 +145,33 @@
  actions
+, %7B throwErrors %7D
 ) %7B%0A  fu
@@ -452,24 +452,78 @@
 re(error));%0A
+      if (throwErrors) %7B%0A        throw error;%0A      %7D%0A
     %7D%0A%0A    r

Add option to throw errors