-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: CLI Module
-
2
-
Not Needed
-
Iteration Barcelona
Enterprise replset [direct: primary]> throw 1 Uncaught Enterprise replset [direct: primary]> throw null Enterprise replset [direct: primary]> Enterprise replset [direct: primary]> throw {} Uncaught Enterprise replset [direct: primary]> throw { printable: 1 } Uncaught 1
The first & third one are happening because the MongoshNodeRepl.writer function expects either an Error or a ShellResult, but when it receives a primitive or generally an object that is neither which lacks the ShellResult properties, it ends up being treated like undefined.
The second one is because passing null back to the REPL eval’s callback function as an Error makes it seem like no error occurred.
The best solution is probably to wrap non-Error error values in Errors once evaluation finishes.