4771314
V2EX  ›  Node.js

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

  •  
  •   4771314 · Oct 29, 2020 · 5466 views
    This topic created in 2046 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   ·   1128 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 18:08 · PVG 02:08 · LAX 11:08 · JFK 14:08
    ♥ Do have faith in what you're doing.