比方说,如果我在调用服务时抛出GeneralError,如何使error对象像我想要的那样:
{
"status": "Failed",
"code": "500_1",
"detail": "Something is wrong with your API"
} 我已经尝试在错误的钩子上添加这个
hook => {
hook.error = {
"status": "Failed",
"code": "500_1",
"detail": "Something is wrong with your API"
}
return hook
}但是仍然不能,并且仍然返回羽毛的默认错误对象:
{
"name": "GeneralError",
"message": "Error",
"code": 500,
"className": "general-error",
"data": {},
"errors": {}
}发布于 2019-11-03 02:29:00
所有的羽化错误都可以与自定义消息一起提供,该消息覆盖有效负载中的默认消息:
throw new GeneralError('The server is sleeping. Come back later.');您还可以传递额外的数据和/或错误。所有这些都有文档记录:https://docs.feathersjs.com/api/errors.html
https://stackoverflow.com/questions/58668554
复制相似问题