【发布时间】:2019-09-20 21:22:13
【问题描述】:
我正在使用 strongloop 4 (lb4)。我面临一个问题,即在错误对象中我需要在错误对象中再添加一个自定义参数。
我希望它在全球范围内。对于每个错误,我都想在每个错误消息中添加该自定义参数。
在 loopback4 中,全局错误处理由 src/sequence.ts 完成。
假设错误消息对象是。
{
"error": {
"statusCode": 400,
"name": "xyz",
"message": "firstName is required"
}
}
我想要像这样的错误对象输出。
{
"error": {
"customParam" : "customParam",
"statusCode": 400,
"name": "xyz",
"message": "firstName is required"
}
}
【问题讨论】:
-
发布您的代码并查看如何在 stackoverflow 上提问。
-
已更新,请查收。
标签: node.js api strongloop lookback