Open peakchen90 opened 1 year ago
Hm, why you pass 0
in reject
?
This is just an example, my real case is: Project.reject()
, reject a undefined
Can you try to use Promise.reject(new Error("test"))
?
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
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;
},
});
}
hm, looks good, feel free to send a PR
Hi, I would like to take this issue !!
Hi, I seem to have found a bug:
Environment
Case
Expected output:
Error: 0
But the actual output:
Success