当开发环境为dev, 在id时非正整数的时候,不能正确显示错误信息,终端显示Error 在 lin-validator.js:87:19
来源:5-3 配置文件与在终端显示异常

猴犀利的7号
2019-07-03
写回答
3回答
-
猴犀利的7号
提问者
2019-07-04
const isHttpException = error instanceof HttpException const isDev = global.config.environment === 'dev' if(isDev && !isHttpException){ throw error }
看来源码,是否结合这样判断 就可以解决bug??
112020-04-07 -
猴犀利的7号
提问者
2019-07-04
// exception.js const catchError = async (ctx,next) => { try { await next() } catch(error) { if(global.config.environment === 'dev'){ throw error } if(isHttpException){ ctx.body = { msg: error.msg, error_code: error.errorCode, request_url: `${ctx.method} ${ctx.path}`, } ctx.status = error.code }else { ctx.body = { msg: '未知错误', error_code: 999, request_url: `${ctx.method} ${ctx.path}`, } ctx.status = 500 } } }
// lin-validator.js validate(ctx, alias = {}) { this.alias = alias let params = this._assembleAllParams(ctx) this.data = cloneDeep(params) this.parsed = cloneDeep(params) const memberKeys = findMembers(this, { filter: this._findMembersFilter.bind(this) }) const errorMsgs = [] // const map = new Map(memberKeys) for (let key of memberKeys) { const result = this._check(key, alias) if (!result.success) { errorMsgs.push(result.msg) } } if (errorMsgs.length != 0) { throw new ParameterException(errorMsgs) // 这里会触发error } ctx.v = this return this }
00 -
7七月
2019-07-04
麻烦帖一下代码,Lin-Validator和dev还是prod有什么关系呢?不太明白
042021-12-27
相似问题