Is there any reason to write next(new Error(err))
instead of next(err)
in nodejs?
Without having any context I would presume that err is already an object (as it usually is in node), so there's no reason to create a new object to just pass it along.
You would create a new object in a situation where, well, you wanna create a new error :). As opposed to just passing the existing one along.
next(new Error('Something went wrong'));