【发布时间】:2023-03-11 10:01:01
【问题描述】:
我是 GRPC 新手,我想了解如何使用 gRPC 和 NodeJS 进行错误格式化。
每当我们需要为 gRPC 服务器构建请求处理程序时,我们都会遵循以下模式:
* getFeature request handler. Gets a request with a point, and responds with a
* feature object indicating whether there is a feature at that point.
* @param {EventEmitter} call Call object for the handler to process
* @param {function(Error, feature)} callback Response callback
*/
function getFeature(call, callback) {
callback(null, checkFeature(call.request));
}
我很清楚调用参数是什么,以及如何使用回调。
我的问题是,回调的第一个字段应该是什么样子? 我认为nodeJS中没有错误标准,看起来这应该是gRPC特定的格式。
我环顾四周,有一个gRPC status codes 的标准。那是错误字段吗?表示状态的 int 或 0(或无),如果一切正常?
【问题讨论】: