nomid2 commited on
Commit
3a18bdf
·
verified ·
1 Parent(s): 608a3e0

Upload server.js

Browse files
Files changed (1) hide show
  1. src/server.js +3 -3
src/server.js CHANGED
@@ -28,7 +28,7 @@ app.get('/health', (req, res) => {
28
 
29
  // 全局错误处理中间件
30
  app.use((error, req, res, next) => {
31
- logger.logError('GLOBAL_ERROR', 'UNHANDLED_ERROR', error.message, {
32
  stack: error.stack,
33
  url: req.url,
34
  method: req.method
@@ -44,7 +44,7 @@ app.use((error, req, res, next) => {
44
 
45
  // 全局异常捕获
46
  process.on('uncaughtException', (error) => {
47
- logger.logError('PROCESS_ERROR', 'UNCAUGHT_EXCEPTION', error.message, {
48
  stack: error.stack
49
  })
50
  console.error('未捕获的异常:', error)
@@ -52,7 +52,7 @@ process.on('uncaughtException', (error) => {
52
  })
53
 
54
  process.on('unhandledRejection', (reason, promise) => {
55
- logger.logError('PROCESS_ERROR', 'UNHANDLED_REJECTION', String(reason), {
56
  promise: promise.toString()
57
  })
58
  console.error('未处理的 Promise 拒绝:', reason)
 
28
 
29
  // 全局错误处理中间件
30
  app.use((error, req, res, next) => {
31
+ logger.logGlobalError('UNHANDLED_ERROR', error.message, {
32
  stack: error.stack,
33
  url: req.url,
34
  method: req.method
 
44
 
45
  // 全局异常捕获
46
  process.on('uncaughtException', (error) => {
47
+ logger.logGlobalError('UNCAUGHT_EXCEPTION', error.message, {
48
  stack: error.stack
49
  })
50
  console.error('未捕获的异常:', error)
 
52
  })
53
 
54
  process.on('unhandledRejection', (reason, promise) => {
55
+ logger.logGlobalError('UNHANDLED_REJECTION', String(reason), {
56
  promise: promise.toString()
57
  })
58
  console.error('未处理的 Promise 拒绝:', reason)