const catchErrorAsync = require('catch-error-async');
// throw error with `message` and `code` from arguments
const cb = async (message, code) => {
await new Promise((resolve, reject) => {
setTimeout(() => reject({ message, code }), 0);
});
};
const error = await catchErrorAsync(cb, 'Mu-ha-ha!', 400);
console.log(error.message); // 'Mu-ha-ha!'
console.log(error.code); // 400
-
Notifications
You must be signed in to change notification settings - Fork 0
Zhigalov/catch-error-async
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Catching errors с by async function
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published