[英]Hyperledger Fabric return json in shim.Error()
I am using Hyperledger Fabric
for implementing blockchain and using Golang
for writing chaincode
. 我正在使用
Hyperledger Fabric
实施Hyperledger Fabric
链并使用Golang
编写chaincode
。
I am able to send JSON
in shim.Success()
since it ask for byte array. 我能够在
shim.Success()
发送JSON
,因为它要求字节数组。 The issue is I am not able to send JSON
in shim.Error()
. 问题是我无法在
shim.Error()
发送JSON
。 I am using node.js
sdk. 我正在使用
node.js
sdk。 It returns me a response with the following string 它返回一个带有以下字符串的响应
"chaincode error (status: 500, message: The email or password you have entered is wrong.)"
Is there any mechanism to parse this response? 有什么机制可以解析此响应? I want to get value of status and message.
我想获取状态和消息的价值。 Please let me know if it possible.
请让我知道是否可能。
If anyone knows how to send JSON in shim.Error()
please comment or submit an answer. 如果有人知道如何在
shim.Error()
发送JSON,请发表评论或提交答案。
Any help/comment would be appreciated. 任何帮助/评论将不胜感激。
You can use 您可以使用
shim.error(new Error("Stringified JSON"));
or alternatively use 或者使用
try {
// Do Something
throw new Error(JSON.stringify(errorJsonObject)); // Throw error wrapped in Error Object
} catch (err) {
console.log(err);
return shim.error(err);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.