diff --git a/doc/api/timers.md b/doc/api/timers.md index ac63d1e63ef7b3..71079343db3aad 100644 --- a/doc/api/timers.md +++ b/doc/api/timers.md @@ -264,7 +264,7 @@ const signal = ac.signal; setImmediatePromise('foobar', { signal }) .then(console.log) .catch((err) => { - if (err.message === 'AbortError') + if (err.name === 'AbortError') console.log('The immediate was aborted'); }); @@ -283,7 +283,7 @@ const signal = ac.signal; setTimeoutPromise(1000, 'foobar', { signal }) .then(console.log) .catch((err) => { - if (err.message === 'AbortError') + if (err.name === 'AbortError') console.log('The timeout was aborted'); });