如何限制我的堆栈跟踪? 实际上,在我的json swagger文件中,我定义了一个对象,该对象的字段对应于枚举。
问题:当我输入与枚举不匹配的字符串时。服务器响应提供了太多信息。我想删除或限制我的堆栈跟踪响应。怎么了
我的Yaml挥舞着:
{
"name": "sort",
"in": "query",
"description": "The type of sort we want",
"required": false,
"type": "string",
"enum": [ "ASC", "DESC" ]
}
当我发送带有sort = abcd的Http get时的http响应
Error: Parameter (sort) is not an allowable value (ASC, DESC): abcd
at throwErrorWithCode (/usr/src/app/node_modules/swagger-tools/lib/validators.js:116:13)
at module.exports.validateEnum (/usr/src/app/node_modules/swagger-tools/lib/validators.js:248:5)
at Object.module.exports.validateSchemaConstraints (/usr/src/app/node_modules/swagger-tools/lib/validators.js:629:5)
at validateValue (/usr/src/app/node_modules/swagger-tools/middleware/swagger-validator.js:119:16)
at /usr/src/app/node_modules/swagger-tools/middleware/swagger-validator.js:379:21
at /usr/src/app/node_modules/async/dist/async.js:1135:9
at eachOfArrayLike (/usr/src/app/node_modules/async/dist/async.js:1069:9)
at eachOf (/usr/src/app/node_modules/async/dist/async.js:1117:5)
at _asyncMap (/usr/src/app/node_modules/async/dist/async.js:1133:5)
at Object.map (/usr/src/app/node_modules/async/dist/async.js:1122:16)
我使用服务器节点js。
也许我必须配置我的package.json ???
"scripts": {
"prestart": "npm install",
"start": "node index.js",
"test": "jest --coverage"
},
答案 0 :(得分:0)
您可以尝试在代码中设置“ Error.stackTraceLimit = 10;”。或任意数量的行。