Skip to content

Commit

Permalink
feat: report timeout value on error
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Oct 4, 2018
1 parent 23c3a92 commit abb4afa
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion promise_/timeout.js
Expand Up @@ -15,7 +15,14 @@ module.exports = function (/* timeout */) {
var isSettled = false, timeoutId;
var timeoutCallback = function () {
if (isSettled) return;
reject(customError("Operation timeout", "PROMISE_TIMEOUT"));
reject(
customError(
"Operation timeout (exceed " +
(isValue(timeout) ? timeout + "ms" : "tick") +
")",
"PROMISE_TIMEOUT"
)
);
};
if (isValue(timeout)) timeoutId = setTimeout(timeoutCallback, timeout);
else nextTick(timeoutCallback);
Expand Down

0 comments on commit abb4afa

Please sign in to comment.