q-koa 11.4.5 → 11.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/core/app.js CHANGED
@@ -42,6 +42,7 @@ const {
42
42
  miLimit,
43
43
  } = require('./middlewares')
44
44
  const Validator = require('./validator')
45
+ const { ServiceError } = require('./errors')
45
46
 
46
47
  let spinner
47
48
 
@@ -1930,6 +1931,7 @@ APP.Sequelize = Sequelize
1930
1931
  APP.lodash = _
1931
1932
  APP.Random = Random
1932
1933
  APP.Validator = Validator
1934
+ APP.ServiceError = ServiceError
1933
1935
  APP.moment = moment
1934
1936
  global.moment = moment
1935
1937
  global.Sequelize = Sequelize
package/core/errors.js ADDED
@@ -0,0 +1,8 @@
1
+ class ServiceError extends Error {
2
+ constructor(message) {
3
+ super(message)
4
+ this.type = 'service'
5
+ }
6
+ }
7
+
8
+ exports.ServiceError = ServiceError
@@ -30,7 +30,7 @@ exports.miErrors = () => async (ctx, next) => {
30
30
  content: e.stack,
31
31
  header: ctx.request.header,
32
32
  }
33
- if (app && app.model && app.model.log) {
33
+ if (['service'].includes(e.type) && app && app.model && app.model.log) {
34
34
  app.model.log.upsert(errorData)
35
35
  }
36
36
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q-koa",
3
- "version": "11.4.5",
3
+ "version": "11.4.6",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {