我正在努力阅读从链码返回的状态码。
我正在使用结构节点SDK进行以下调用:
results = await channel.sendTransactionProposal(request);
其中channel是节点SDK中的Channel
对象。
我的链码拒绝了该请求,并返回HTTP状态码500。节点SDK抛出未设置状态码的异常。深入研究代码,我在Fabric-client的Peer.js
中发现了以下代码,该代码引发错误:
if (proposalResponse) {
logger.debug('%s - Received proposal response from peer "%s": status - %s', method, self._url, proposalResponse.response.status);
// 400 is the error threshold level, anything below that the endorser will endorse it.
if (proposalResponse.response && proposalResponse.response.status < 400) {
resolve(proposalResponse);
} else if (proposalResponse.response && proposalResponse.response.message) {
reject(new Error(proposalResponse.response.message));
} else {
logger.error('GRPC client failed to get a proper response from the peer "%s".', self._url);
reject(new Error(util.format('GRPC client failed to get a proper response from the peer "%s".', self._url)));
}
} else {
logger.error('GRPC client got a null or undefined response from the peer "%s".', self._url);
reject(new Error(util.format('GRPC client got a null or undefined response from the peer "%s".', self._url)));
}
第reject(new Error(proposalResponse.response.message));
行引发了错误,并且状态代码显然丢失了。这是在fabric-client的1.2.2版本上,可以在这里找到:
https://github.com/hyperledger/fabric-sdk-node/tree/v1.2.2
是否有任何解决方法,还是我们必须等待更新的版本?看来该问题已在v1.3中解决(是否仅与Fabric v1.3兼容?
谢谢