4 Star 7 Fork 5

Alisheng / pinus-game

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
preload.ts 1.10 KB
一键复制 编辑 原始数据 按行查看 历史
Alisheng 提交于 2021-09-01 18:38 . 初始化项目
import { Promise } from 'bluebird';
// 支持注解
import 'reflect-metadata';
import { pinus } from 'pinus';
/**
* 替换全局Promise
* 自动解析sourcemap
* 捕获全局错误
*/
export function preload() {
// 使用bluebird输出完整的promise调用链
((global as any).Promise as any) = (Promise as any);
// 开启长堆栈
Promise.config({
// Enable warnings
warnings: true,
// Enable long stack traces
longStackTraces: true,
// Enable cancellation
cancellation: true,
// Enable monitoring
monitoring: true
});
// 自动解析ts的sourcemap
require('source-map-support').install({
handleUncaughtExceptions: false
});
// 捕获普通异常
process.on('uncaughtException', function (err) {
console.error(pinus.app.getServerId(), 'uncaughtException Caught exception: ', err);
});
// 捕获async异常
process.on('unhandledRejection', (reason: any, p) => {
console.error(pinus.app.getServerId(), 'Caught Unhandled Rejection at:', p, 'reason:', reason);
});
}
NodeJS
1
https://gitee.com/Alisheng/pinus-game.git
git@gitee.com:Alisheng/pinus-game.git
Alisheng
pinus-game
pinus-game
master

搜索帮助