Here is the thing tho, if you use asyncErrorHandler function which handles all rejections you don't really need next(error) instead you can throw the error and it will be caught by the middleware and then passed to the middleware that handles errors
I love this tutorial. However, i was thinking we can throw an error if we can find the movie so that the wrapper function can handle it for us. Thanks for this tutorial
6:40 we can also throw a new CustomError as an error link this => throw new CustomError({ message: "Movie with that ID is not found!", statusCode: 404 }); this will handle by asyncErrorHandler function
So you can move all the catch(error) handling from your async functions to the asyncErrorHandler, instead of repeating the same thing in each async function
Async is always returning promises .. and promises have then and catch properties .... So we are thinking in such a way that we don't have to repeat a code .. so just for that we created a function which takes function as a parameter. And will be called when we do request .. and the reason is .. we are calling the function using calback .. and when express catch some error that callback will be triggered and then called ...and there you see we used next(err), that will trigger the error handling middle ware .. and we can get response to json format... If error occurs
I'm so pained that I'm just seeing your vids. Custom error brought me here but so far you are one of my fav tutors sir.
Here is the thing tho, if you use asyncErrorHandler function which handles all rejections you don't really need next(error) instead you can throw the error and it will be caught by the middleware and then passed to the middleware that handles errors
I love this tutorial. However, i was thinking we can throw an error if we can find the movie so that the wrapper function can handle it for us. Thanks for this tutorial
6:40 we can also throw a new CustomError as an error link this => throw new CustomError({ message: "Movie with that ID is not found!", statusCode: 404 });
this will handle by asyncErrorHandler function
❤❤
error handling so difficult to understad
Why did you applied the asynErrorHandler in updateMovie
So you can move all the catch(error) handling from your async functions to the asyncErrorHandler, instead of repeating the same thing in each async function
Async is always returning promises .. and promises have then and catch properties .... So we are thinking in such a way that we don't have to repeat a code .. so just for that we created a function which takes function as a parameter. And will be called when we do request .. and the reason is .. we are calling the function using calback .. and when express catch some error that callback will be triggered and then called ...and there you see we used next(err), that will trigger the error handling middle ware .. and we can get response to json format... If error occurs
I dont know either this guy copied the content of jonas schmedman or jonas did copy... It is exactly the same that i learned in the paid course
yeah, this guy copied from jonas
❤❤❤