Repository: webpack/tapable

Issue:
[Bug] Async hook doesn't catch error when reject a falsy value
Hi, I seem to have found a bug:

### Environment
- Tapable: v2.2.1
- Node: v16.16.0
- OS: MacOS 12.5

### Case

```js
const { AsyncSeriesHook } = require('tapable');

const hook = new AsyncSeriesHook();
hook.tapPromise('A', () => {
  return Promise.reject(0); // reject a falsy value
});
hook.tapPromise('B', () => {
  console.log('some thing');
});

hook.callAsync((err) => {
  if (err) {
    console.error('Error:', err);
  } else {
    console.log('Success');
  }
});
```

**Expected output**: `Error: 0`

**But the actual output**: `Success`


Hints from issue comments:
@alexander-akait: Hm, why you pass `0` in `reject`?@peakchen90: This is just an example, my real case is: `Project.reject()` , reject a `undefined` @alexander-akait: Can you try to use `Promise.reject(new Error("test"))`?@peakchen90: Of course, I can somehow ignore this case, but I think this can be made more robust. I don't use hooks directly, and I expose them to others, so I have to fix. Below shows how I fixed it. and I hope the official can fix it

```ts
function _fixTapablePromiseHook(hook: Hook<any, any>) {
  hook.intercept({
    register: (tapInfo) => {
      const originalFn = tapInfo.fn;
      if (tapInfo.type === 'promise') {
        tapInfo.fn = async function (...args: any[]) {
          try {
            return await originalFn.apply(tapInfo, args);
          } catch (err) {
            if (!err) err = new Error();
            throw err;
          }
        };
      }
      return tapInfo;
    },
  });
}
```@alexander-akait: hm, looks good, feel free to send a PR@Steven19Lee: Hi, I would like to take this issue !!

Solution patch:
diff --git a/README.md b/README.md
index 9a2f92c..53fd476 100644
--- a/README.md
+++ b/README.md
@@ -70,12 +70,11 @@ For sync hooks, `tap` is the only valid method to add a plugin. Async hooks also
 ```js
 myCar.hooks.calculateRoutes.tapPromise(
 	"GoogleMapsPlugin",
-	(source, target, routesList) => 
+	(source, target, routesList) =>
 		// return a promise
-		 google.maps.findRoute(source, target).then((route) => {
+		google.maps.findRoute(source, target).then((route) => {
 			routesList.add(route);
 		})
-	
 );
 myCar.hooks.calculateRoutes.tapAsync(
 	"BingMapsPlugin",
@@ -117,9 +116,9 @@ class Car {
 		const routesList = new List();
 		return this.hooks.calculateRoutes
 			.promise(source, target, routesList)
-			.then((res) => 
+			.then((res) =>
 				// res is undefined for AsyncParallelHook
-				 routesList.getRoutes()
+				routesList.getRoutes()
 			);
 	}
 
@@ -263,7 +262,11 @@ interface Hook {
 	tap: (name: string | Tap, fn: (context?, ...args) => Result) => void;
 	tapAsync: (
 		name: string | Tap,
-		fn: (context?, ...args, callback: (err, result: Result) => void) => void
+		fn: (
+			context?,
+			...args,
+			callback: (err: Error | null, result: Result) => void
+		) => void
 	) => void;
 	tapPromise: (
 		name: string | Tap,
@@ -306,7 +309,10 @@ interface Hook {
 	isUsed: () => boolean;
 	call: (...args) => Result;
 	promise: (...args) => Promise<Result>;
-	callAsync: (...args, callback: (err, result: Result) => void) => void;
+	callAsync: (
+		...args,
+		callback: (err: Error | null, result: Result) => void
+	) => void;
 }
 
 interface HookMap {
diff --git a/lib/HookCodeFactory.js b/lib/HookCodeFactory.js
index 8407681..67e4663 100644
--- a/lib/HookCodeFactory.js
+++ b/lib/HookCodeFactory.js
@@ -257,7 +257,9 @@ class HookCodeFactory {
 				}
 				code += `}), function(_err${tapIndex}) {\n`;
 				code += `if(_hasResult${tapIndex}) throw _err${tapIndex};\n`;
-				code += onError(`_err${tapIndex}`);
+				code += onError(
+					`!_err${tapIndex} ? new Error('Tap function (tapPromise) rejects "' + _err${tapIndex} + '" value') : _err${tapIndex}`
+				);
 				code += "});\n";
 				break;
 		}
diff --git a/package.json b/package.json
index 3deb955..1231db2 100644
--- a/package.json
+++ b/package.json
@@ -20,11 +20,11 @@
   "types": "./tapable.d.ts",
   "files": ["lib", "!lib/__tests__", "tapable.d.ts"],
   "scripts": {
-    "lint": "yarn lint:code",
+    "lint": "yarn lint:code && yarn fmt:check",
     "lint:code": "eslint --cache .",
     "fmt": "yarn fmt:base --log-level warn --write",
     "fmt:check": "yarn fmt:base --check",
-    "fmt:base": "node prettier --cache --ignore-unknown .",
+    "fmt:base": "node ./node_modules/prettier/bin/prettier.cjs --cache --ignore-unknown .",
     "fix": "yarn fix:code && yarn fmt",
     "fix:code": "yarn lint:code --fix",
     "test": "jest"



Test patch:
diff --git a/lib/__tests__/HookTester.js b/lib/__tests__/HookTester.js
index 11aa938..7ba800a 100644
--- a/lib/__tests__/HookTester.js
+++ b/lib/__tests__/HookTester.js
@@ -665,6 +665,60 @@ class HookTester {
 			);
 		}
 
+		{
+			const hook = this.createHook(["x"], `${type}SinglePromiseWithNullReject`);
+			// eslint-disable-next-line prefer-promise-reject-errors
+			hook.tapPromise("promise", (_arg) => Promise.reject(null));
+			result[`${type}SinglePromiseWithNullReject`] = await this.gainResult(
+				(cb) => hook[type](null, cb)
+			);
+		}
+
+		{
+			const hook = this.createHook(
+				["x"],
+				`${type}SinglePromiseWithUndefinedReject`
+			);
+			// eslint-disable-next-line prefer-promise-reject-errors
+			hook.tapPromise("promise", (_arg) => Promise.reject(undefined));
+			result[`${type}SinglePromiseWithUndefinedReject`] = await this.gainResult(
+				(cb) => hook[type](null, cb)
+			);
+		}
+
+		{
+			const hook = this.createHook(["x"], `${type}SinglePromiseWithZeroReject`);
+			// eslint-disable-next-line prefer-promise-reject-errors
+			hook.tapPromise("promise", (_arg) => Promise.reject(0));
+			result[`${type}SinglePromiseWithZeroReject`] = await this.gainResult(
+				(cb) => hook[type](null, cb)
+			);
+		}
+
+		{
+			const hook = this.createHook(
+				["x"],
+				`${type}SinglePromiseWithFalseReject`
+			);
+			// eslint-disable-next-line prefer-promise-reject-errors
+			hook.tapPromise("promise", (_arg) => Promise.reject(false));
+			result[`${type}SinglePromiseWithFalseReject`] = await this.gainResult(
+				(cb) => hook[type](null, cb)
+			);
+		}
+
+		{
+			const hook = this.createHook(
+				["x"],
+				`${type}SinglePromiseWithEmptyReject`
+			);
+			// eslint-disable-next-line prefer-promise-reject-errors
+			hook.tapPromise("promise", (_arg) => Promise.reject(""));
+			result[`${type}SinglePromiseWithEmptyReject`] = await this.gainResult(
+				(cb) => hook[type](null, cb)
+			);
+		}
+
 		{
 			const hook = this.createHook(["x"], `${type}MultiplePromiseWithArg`);
 			hook.tapPromise("promise1", (arg) => {
diff --git a/lib/__tests__/__snapshots__/AsyncParallelHooks.js.snap b/lib/__tests__/__snapshots__/AsyncParallelHooks.js.snap
index 0392a16..c90efe1 100644
--- a/lib/__tests__/__snapshots__/AsyncParallelHooks.js.snap
+++ b/lib/__tests__/__snapshots__/AsyncParallelHooks.js.snap
@@ -195,6 +195,26 @@ Object {
       "value": 43,
     },
     "callAsyncSinglePromiseWithArgCalled1": 42,
+    "callAsyncSinglePromiseWithEmptyReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"\\" value",
+      "type": "async",
+    },
+    "callAsyncSinglePromiseWithFalseReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"false\\" value",
+      "type": "async",
+    },
+    "callAsyncSinglePromiseWithNullReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"null\\" value",
+      "type": "async",
+    },
+    "callAsyncSinglePromiseWithUndefinedReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"undefined\\" value",
+      "type": "async",
+    },
+    "callAsyncSinglePromiseWithZeroReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"0\\" value",
+      "type": "async",
+    },
     "callAsyncSingleSync": Object {
       "type": "async",
       "value": 42,
@@ -402,6 +422,26 @@ Object {
       "value": 43,
     },
     "promiseSinglePromiseWithArgCalled1": 42,
+    "promiseSinglePromiseWithEmptyReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"\\" value",
+      "type": "promise",
+    },
+    "promiseSinglePromiseWithFalseReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"false\\" value",
+      "type": "promise",
+    },
+    "promiseSinglePromiseWithNullReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"null\\" value",
+      "type": "promise",
+    },
+    "promiseSinglePromiseWithUndefinedReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"undefined\\" value",
+      "type": "promise",
+    },
+    "promiseSinglePromiseWithZeroReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"0\\" value",
+      "type": "promise",
+    },
     "promiseSingleSync": Object {
       "type": "promise",
       "value": 42,
@@ -925,6 +965,26 @@ Object {
       "value": undefined,
     },
     "callAsyncSinglePromiseWithArgCalled1": 42,
+    "callAsyncSinglePromiseWithEmptyReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"\\" value",
+      "type": "async",
+    },
+    "callAsyncSinglePromiseWithFalseReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"false\\" value",
+      "type": "async",
+    },
+    "callAsyncSinglePromiseWithNullReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"null\\" value",
+      "type": "async",
+    },
+    "callAsyncSinglePromiseWithUndefinedReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"undefined\\" value",
+      "type": "async",
+    },
+    "callAsyncSinglePromiseWithZeroReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"0\\" value",
+      "type": "async",
+    },
     "callAsyncSingleSync": Object {
       "type": "async",
       "value": undefined,
@@ -1145,6 +1205,26 @@ Object {
       "value": undefined,
     },
     "promiseSinglePromiseWithArgCalled1": 42,
+    "promiseSinglePromiseWithEmptyReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"\\" value",
+      "type": "promise",
+    },
+    "promiseSinglePromiseWithFalseReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"false\\" value",
+      "type": "promise",
+    },
+    "promiseSinglePromiseWithNullReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"null\\" value",
+      "type": "promise",
+    },
+    "promiseSinglePromiseWithUndefinedReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"undefined\\" value",
+      "type": "promise",
+    },
+    "promiseSinglePromiseWithZeroReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"0\\" value",
+      "type": "promise",
+    },
     "promiseSingleSync": Object {
       "type": "promise",
       "value": undefined,
diff --git a/lib/__tests__/__snapshots__/AsyncSeriesHooks.js.snap b/lib/__tests__/__snapshots__/AsyncSeriesHooks.js.snap
index d3d8dcc..0c2f28f 100644
--- a/lib/__tests__/__snapshots__/AsyncSeriesHooks.js.snap
+++ b/lib/__tests__/__snapshots__/AsyncSeriesHooks.js.snap
@@ -184,6 +184,26 @@ Object {
       "value": 43,
     },
     "callAsyncSinglePromiseWithArgCalled1": 42,
+    "callAsyncSinglePromiseWithEmptyReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"\\" value",
+      "type": "async",
+    },
+    "callAsyncSinglePromiseWithFalseReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"false\\" value",
+      "type": "async",
+    },
+    "callAsyncSinglePromiseWithNullReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"null\\" value",
+      "type": "async",
+    },
+    "callAsyncSinglePromiseWithUndefinedReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"undefined\\" value",
+      "type": "async",
+    },
+    "callAsyncSinglePromiseWithZeroReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"0\\" value",
+      "type": "async",
+    },
     "callAsyncSingleSync": Object {
       "type": "async",
       "value": 42,
@@ -380,6 +400,26 @@ Object {
       "value": 43,
     },
     "promiseSinglePromiseWithArgCalled1": 42,
+    "promiseSinglePromiseWithEmptyReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"\\" value",
+      "type": "promise",
+    },
+    "promiseSinglePromiseWithFalseReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"false\\" value",
+      "type": "promise",
+    },
+    "promiseSinglePromiseWithNullReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"null\\" value",
+      "type": "promise",
+    },
+    "promiseSinglePromiseWithUndefinedReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"undefined\\" value",
+      "type": "promise",
+    },
+    "promiseSinglePromiseWithZeroReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"0\\" value",
+      "type": "promise",
+    },
     "promiseSingleSync": Object {
       "type": "promise",
       "value": 42,
@@ -894,6 +934,26 @@ Object {
       "value": undefined,
     },
     "callAsyncSinglePromiseWithArgCalled1": 42,
+    "callAsyncSinglePromiseWithEmptyReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"\\" value",
+      "type": "async",
+    },
+    "callAsyncSinglePromiseWithFalseReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"false\\" value",
+      "type": "async",
+    },
+    "callAsyncSinglePromiseWithNullReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"null\\" value",
+      "type": "async",
+    },
+    "callAsyncSinglePromiseWithUndefinedReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"undefined\\" value",
+      "type": "async",
+    },
+    "callAsyncSinglePromiseWithZeroReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"0\\" value",
+      "type": "async",
+    },
     "callAsyncSingleSync": Object {
       "type": "async",
       "value": undefined,
@@ -1105,6 +1165,26 @@ Object {
       "value": undefined,
     },
     "promiseSinglePromiseWithArgCalled1": 42,
+    "promiseSinglePromiseWithEmptyReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"\\" value",
+      "type": "promise",
+    },
+    "promiseSinglePromiseWithFalseReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"false\\" value",
+      "type": "promise",
+    },
+    "promiseSinglePromiseWithNullReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"null\\" value",
+      "type": "promise",
+    },
+    "promiseSinglePromiseWithUndefinedReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"undefined\\" value",
+      "type": "promise",
+    },
+    "promiseSinglePromiseWithZeroReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"0\\" value",
+      "type": "promise",
+    },
     "promiseSingleSync": Object {
       "type": "promise",
       "value": undefined,
@@ -1735,6 +1815,26 @@ Object {
       "value": 43,
     },
     "callAsyncSinglePromiseWithArgCalled1": 42,
+    "callAsyncSinglePromiseWithEmptyReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"\\" value",
+      "type": "async",
+    },
+    "callAsyncSinglePromiseWithFalseReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"false\\" value",
+      "type": "async",
+    },
+    "callAsyncSinglePromiseWithNullReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"null\\" value",
+      "type": "async",
+    },
+    "callAsyncSinglePromiseWithUndefinedReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"undefined\\" value",
+      "type": "async",
+    },
+    "callAsyncSinglePromiseWithZeroReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"0\\" value",
+      "type": "async",
+    },
     "callAsyncSingleSync": Object {
       "error": "Waterfall hooks must have at least one argument",
     },
@@ -1914,6 +2014,26 @@ Object {
       "value": 43,
     },
     "promiseSinglePromiseWithArgCalled1": 42,
+    "promiseSinglePromiseWithEmptyReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"\\" value",
+      "type": "promise",
+    },
+    "promiseSinglePromiseWithFalseReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"false\\" value",
+      "type": "promise",
+    },
+    "promiseSinglePromiseWithNullReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"null\\" value",
+      "type": "promise",
+    },
+    "promiseSinglePromiseWithUndefinedReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"undefined\\" value",
+      "type": "promise",
+    },
+    "promiseSinglePromiseWithZeroReject": Object {
+      "error": "Tap function (tapPromise) rejects \\"0\\" value",
+      "type": "promise",
+    },
     "promiseSingleSync": Object {
       "error": "Waterfall hooks must have at least one argument",
     },
diff --git a/lib/__tests__/__snapshots__/HookCodeFactory.js.snap b/lib/__tests__/__snapshots__/HookCodeFactory.js.snap
index 5f15542..10e1dd4 100644
--- a/lib/__tests__/__snapshots__/HookCodeFactory.js.snap
+++ b/lib/__tests__/__snapshots__/HookCodeFactory.js.snap
@@ -59,7 +59,7 @@ _hasResult2 = true;
 onResult(_result2);
 }), function(_err2) {
 if(_hasResult2) throw _err2;
-onError(_err2);
+onError(!_err2 ? new Error('Tap function (tapPromise) rejects \\"' + _err2 + '\\" value') : _err2);
 });
 "
 `;
@@ -81,7 +81,11 @@ _promise2.then(
   },
   function(_err2) {
     if (_hasResult2) throw _err2;
-    onError(_err2);
+    onError(
+      !_err2
+        ? new Error('Tap function (tapPromise) rejects \\"' + _err2 + '\\" value')
+        : _err2
+    );
   }
 );
 "
@@ -98,7 +102,7 @@ _hasResult2 = true;
 onDone();
 }), function(_err2) {
 if(_hasResult2) throw _err2;
-onError(_err2);
+onError(!_err2 ? new Error('Tap function (tapPromise) rejects \\"' + _err2 + '\\" value') : _err2);
 });
 "
 `;
@@ -120,7 +124,11 @@ _promise2.then(
   },
   function(_err2) {
     if (_hasResult2) throw _err2;
-    onError(_err2);
+    onError(
+      !_err2
+        ? new Error('Tap function (tapPromise) rejects \\"' + _err2 + '\\" value')
+        : _err2
+    );
   }
 );
 "
@@ -245,7 +253,7 @@ _hasResult2 = true;
 onResult(_result2);
 }), function(_err2) {
 if(_hasResult2) throw _err2;
-onError(_err2);
+onError(!_err2 ? new Error('Tap function (tapPromise) rejects \\"' + _err2 + '\\" value') : _err2);
 });
 "
 `;
@@ -267,7 +275,11 @@ _promise2.then(
   },
   function(_err2) {
     if (_hasResult2) throw _err2;
-    onError(_err2);
+    onError(
+      !_err2
+        ? new Error('Tap function (tapPromise) rejects \\"' + _err2 + '\\" value')
+        : _err2
+    );
   }
 );
 "
@@ -284,7 +296,7 @@ _hasResult2 = true;
 onDone();
 }), function(_err2) {
 if(_hasResult2) throw _err2;
-onError(_err2);
+onError(!_err2 ? new Error('Tap function (tapPromise) rejects \\"' + _err2 + '\\" value') : _err2);
 });
 "
 `;
@@ -306,7 +318,11 @@ _promise2.then(
   },
   function(_err2) {
     if (_hasResult2) throw _err2;
-    onError(_err2);
+    onError(
+      !_err2
+        ? new Error('Tap function (tapPromise) rejects \\"' + _err2 + '\\" value')
+        : _err2
+    );
   }
 );
 "
@@ -446,7 +462,7 @@ _hasResult2 = true;
 onResult(_result2);
 }), function(_err2) {
 if(_hasResult2) throw _err2;
-onError(_err2);
+onError(!_err2 ? new Error('Tap function (tapPromise) rejects \\"' + _err2 + '\\" value') : _err2);
 });
 "
 `;
@@ -471,7 +487,11 @@ _promise2.then(
   },
   function(_err2) {
     if (_hasResult2) throw _err2;
-    onError(_err2);
+    onError(
+      !_err2
+        ? new Error('Tap function (tapPromise) rejects \\"' + _err2 + '\\" value')
+        : _err2
+    );
   }
 );
 "
@@ -491,7 +511,7 @@ _hasResult2 = true;
 onDone();
 }), function(_err2) {
 if(_hasResult2) throw _err2;
-onError(_err2);
+onError(!_err2 ? new Error('Tap function (tapPromise) rejects \\"' + _err2 + '\\" value') : _err2);
 });
 "
 `;
@@ -516,7 +536,11 @@ _promise2.then(
   },
   function(_err2) {
     if (_hasResult2) throw _err2;
-    onError(_err2);
+    onError(
+      !_err2
+        ? new Error('Tap function (tapPromise) rejects \\"' + _err2 + '\\" value')
+        : _err2
+    );
   }
 );
 "
@@ -618,7 +642,7 @@ onDone();
 }
 }), function(_err2) {
 if(_hasResult2) throw _err2;
-onError(2, _err2);
+onError(2, !_err2 ? new Error('Tap function (tapPromise) rejects \\"' + _err2 + '\\" value') : _err2);
 });
 }
 var _fn0 = _x[0];
@@ -686,7 +710,14 @@ exports[`HookCodeFactory taps (mixed) callTapsLooping 2`] = `
         },
         function(_err2) {
           if (_hasResult2) throw _err2;
-          onError(2, _err2);
+          onError(
+            2,
+            !_err2
+              ? new Error(
+                  'Tap function (tapPromise) rejects \\"' + _err2 + '\\" value'
+                )
+              : _err2
+          );
         }
       );
     }
@@ -779,7 +810,7 @@ _done();
 }), function(_err2) {
 if(_hasResult2) throw _err2;
 if(_counter > 0) {
-onError(2, _err2);
+onError(2, !_err2 ? new Error('Tap function (tapPromise) rejects \\"' + _err2 + '\\" value') : _err2);
 }
 });
 } while(false);
@@ -861,7 +892,14 @@ exports[`HookCodeFactory taps (mixed) callTapsParallel 2`] = `
     function(_err2) {
       if (_hasResult2) throw _err2;
       if (_counter > 0) {
-        onError(2, _err2);
+        onError(
+          2,
+          !_err2
+            ? new Error(
+                'Tap function (tapPromise) rejects \\"' + _err2 + '\\" value'
+              )
+            : _err2
+        );
       }
     }
   );
@@ -885,7 +923,7 @@ onDone();
 });
 }), function(_err2) {
 if(_hasResult2) throw _err2;
-onError(2, _err2);
+onError(2, !_err2 ? new Error('Tap function (tapPromise) rejects \\"' + _err2 + '\\" value') : _err2);
 });
 }
 var _fn0 = _x[0];
@@ -936,7 +974,12 @@ exports[`HookCodeFactory taps (mixed) callTapsSeries 2`] = `
     },
     function(_err2) {
       if (_hasResult2) throw _err2;
-      onError(2, _err2);
+      onError(
+        2,
+        !_err2
+          ? new Error('Tap function (tapPromise) rejects \\"' + _err2 + '\\" value')
+          : _err2
+      );
     }
   );
 }
@@ -1013,7 +1056,7 @@ _next1();
 }
 }), function(_err1) {
 if(_hasResult1) throw _err1;
-onError(1, _err1);
+onError(1, !_err1 ? new Error('Tap function (tapPromise) rejects \\"' + _err1 + '\\" value') : _err1);
 });
 }
 var _fn0 = _x[0];
@@ -1084,7 +1127,14 @@ exports[`HookCodeFactory taps (mixed2) callTapsLooping 2`] = `
         },
         function(_err1) {
           if (_hasResult1) throw _err1;
-          onError(1, _err1);
+          onError(
+            1,
+            !_err1
+              ? new Error(
+                  'Tap function (tapPromise) rejects \\"' + _err1 + '\\" value'
+                )
+              : _err1
+          );
         }
       );
     }
@@ -1151,7 +1201,7 @@ _done();
 }), function(_err1) {
 if(_hasResult1) throw _err1;
 if(_counter > 0) {
-onError(1, _err1);
+onError(1, !_err1 ? new Error('Tap function (tapPromise) rejects \\"' + _err1 + '\\" value') : _err1);
 }
 });
 if(_counter <= 0) break;
@@ -1228,7 +1278,14 @@ exports[`HookCodeFactory taps (mixed2) callTapsParallel 2`] = `
     function(_err1) {
       if (_hasResult1) throw _err1;
       if (_counter > 0) {
-        onError(1, _err1);
+        onError(
+          1,
+          !_err1
+            ? new Error(
+                'Tap function (tapPromise) rejects \\"' + _err1 + '\\" value'
+              )
+            : _err1
+        );
       }
     }
   );
@@ -1285,7 +1342,7 @@ onDone();
 });
 }), function(_err1) {
 if(_hasResult1) throw _err1;
-onError(1, _err1);
+onError(1, !_err1 ? new Error('Tap function (tapPromise) rejects \\"' + _err1 + '\\" value') : _err1);
 });
 }
 var _fn0 = _x[0];
@@ -1352,7 +1409,12 @@ function _next0() {
     },
     function(_err1) {
       if (_hasResult1) throw _err1;
-      onError(1, _err1);
+      onError(
+        1,
+        !_err1
+          ? new Error('Tap function (tapPromise) rejects \\"' + _err1 + '\\" value')
+          : _err1
+      );
     }
   );
 }
@@ -1779,7 +1841,7 @@ onDone();
 }
 }), function(_err0) {
 if(_hasResult0) throw _err0;
-onError(0, _err0);
+onError(0, !_err0 ? new Error('Tap function (tapPromise) rejects \\"' + _err0 + '\\" value') : _err0);
 });
 } while(_loop);
 _loopAsync = true;
@@ -1817,7 +1879,14 @@ exports[`HookCodeFactory taps (single promise) callTapsLooping 2`] = `
       },
       function(_err0) {
         if (_hasResult0) throw _err0;
-        onError(0, _err0);
+        onError(
+          0,
+          !_err0
+            ? new Error(
+                'Tap function (tapPromise) rejects \\"' + _err0 + '\\" value'
+              )
+            : _err0
+        );
       }
     );
   } while (_loop);
@@ -1842,7 +1911,7 @@ onDone();
 });
 }), function(_err0) {
 if(_hasResult0) throw _err0;
-onError(0, _err0);
+onError(0, !_err0 ? new Error('Tap function (tapPromise) rejects \\"' + _err0 + '\\" value') : _err0);
 });
 "
 `;
@@ -1873,7 +1942,12 @@ _promise0.then(
   },
   function(_err0) {
     if (_hasResult0) throw _err0;
-    onError(0, _err0);
+    onError(
+      0,
+      !_err0
+        ? new Error('Tap function (tapPromise) rejects \\"' + _err0 + '\\" value')
+        : _err0
+    );
   }
 );
 "
@@ -1894,7 +1968,7 @@ onDone();
 });
 }), function(_err0) {
 if(_hasResult0) throw _err0;
-onError(0, _err0);
+onError(0, !_err0 ? new Error('Tap function (tapPromise) rejects \\"' + _err0 + '\\" value') : _err0);
 });
 "
 `;
@@ -1925,7 +1999,12 @@ _promise0.then(
   },
   function(_err0) {
     if (_hasResult0) throw _err0;
-    onError(0, _err0);
+    onError(
+      0,
+      !_err0
+        ? new Error('Tap function (tapPromise) rejects \\"' + _err0 + '\\" value')
+        : _err0
+    );
   }
 );
 "