4771314
V2EX  ›  Node.js

关于 process.on uncaughtException unhandledRejection 使用的疑问

  •  
  •   4771314 · Oct 29, 2020 · 5541 views
    This topic created in 2082 days ago, the information mentioned may be changed or developed.
    process.on('uncaughtException',function name(error) {
        const msg = error ? Err.getThrowableMessage(error) : '未知错误';
        logger.error('全局异常 uncaughtException:' +  msg);
    });
    
    process.on('unhandledRejection',function name(error) {
        const msg = error ? Err.getThrowableMessage(error) : '未知错误';
        monitor.report(MONITOR.TEST_PORTRAIT_GLOBAL_REJECTION_COUNT);
    });
    

    server 需要用这种方式保证服务的稳定吗? 使用的是 koa 的框架

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3686 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 00:47 · PVG 08:47 · LAX 17:47 · JFK 20:47
    ♥ Do have faith in what you're doing.