Browse Source

refactor: 异常处理

modood 7 năm trước cách đây
mục cha
commit
e55194c99c
2 tập tin đã thay đổi với 8 bổ sung2 xóa
  1. 4 1
      lib/build.js
  2. 4 1
      lib/fetch.js

+ 4 - 1
lib/build.js

@@ -28,4 +28,7 @@ function jsonOut (name, data) {
     JSON.stringify(data))
 }
 
-main()
+main().then(() => process.exit(0)).catch(e => {
+  console.log(e)
+  process.exit(-1)
+})

+ 4 - 1
lib/fetch.js

@@ -9,4 +9,7 @@ async function main () {
   console.log('[100%] 数据抓取完成!')
 }
 
-main()
+main().then(() => process.exit(0)).catch(e => {
+  console.log(e)
+  process.exit(-1)
+})