错误处理
🌐 Error handling
默认情况下,REPL 中未捕获的异常会被打印到输出流(就像上面的 Uncaught Error: REPL await 一样)。uncaughtException 监听器可以在独立 REPL 和嵌套 REPL 中自由添加。repl.start() 的 handleError 选项可以自定义这个行为,包括通过返回 'unhandled' 将异常转发到 'uncaughtException'。
🌐 By default, uncaught exceptions in the REPL are printed to the output stream
(as with Uncaught Error: REPL await above). uncaughtException listeners
can be added freely in both standalone and nested REPLs. The handleError
option of repl.start() can customize this behavior, including
forwarding exceptions to 'uncaughtException' by returning
'unhandled'.