Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- async function startTask(req) {
- const {
- params: {
- userId,
- },
- } = req;
- const user = await getUser(userId)
- .catch((e) => {
- throw new Error('A better error');
- });
- const newTask = await createTask({
- userId,
- name: 'Another task',
- })
- .catch((e) => {
- throw new Error('I like this error better than the "createTask" error');
- });
- await sendNotification()
- .catch((e) => {
- throw new Error('Uh oh');
- });
- await sendNotification()
- .catch((e) => {
- throw new Error('Uh oh again!');
- });
- return newTask;
- }
- function callsStartTask() {
- startTask(req)
- .then(newTask => {
- res.send(newTask)
- })
- .catch((e) => {
- res.status(e.statusCode).send(e.message)
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement