如何通过loopback-api返回自定义的错误消息?

时间:2019-04-02 05:13:24

标签: rest hyperledger-fabric loopbackjs

问题是该错误以特定格式出现,而不是简单的语言。

这就是我得到的:

{
  "error": {
    "statusCode": 500,
    "name": "Error",
    "message": "Invalid JSON data. Found a value that is not a string: 1111 for relationship RelationshipDeclaration {name=asset, type=org.example.mynetwork.SampleAsset, array=false, optional=false}",
    "stack": "Error: Invalid JSON data. Found a value that is not a string: 1111 for relationship RelationshipDeclaration {name=asset, type=org.example.mynetwork.SampleAsset, array=false, optional=false}\n    at JSONPopulator.visitRelationshipDeclaration (/home/avinash/modi/sample-network/my-loopback/node_modules/composer-common/lib/serializer/jsonpopulator.js:293:27)\n    at JSONPopulator.visit (/home/avinash/modi/sample-network/my-loopback/node_modules/composer-common/lib/serializer/jsonpopulator.js:102:25)\n    at RelationshipDeclaration.accept (/home/avinash/modi/sample-network/my-loopback/node_modules/composer-common/lib/introspect/decorated.js:65:24)\n    at JSONPopulator.visitClassDeclaration (/home/avinash/modi/sample-network/my-loopback/node_modules/composer-common/lib/serializer/jsonpopulator.js:128:51)\n    at JSONPopulator.visit (/home/avinash/modi/sample-network/my-loopback/node_modules/composer-common/lib/serializer/jsonpopulator.js:100:25)\n    at TransactionDeclaration.accept (/home/avinash/modi/sample-network/my-loopback/node_modules/composer-common/lib/introspect/decorated.js:65:24)\n    at Serializer.fromJSON (/home/avinash/modi/sample-network/my-loopback/node_modules/composer-common/lib/serializer.js:203:26)\n    at ensureConnected.then (/home/avinash/modi/sample-network/my-loopback/node_modules/loopback-connector-composer/lib/businessnetworkconnector.js:635:43)\n    at <anonymous>\n    at process._tickCallback (internal/process/next_tick.js:189:7)"
  }
}

但我希望输出为:请输入正确的输入!

0 个答案:

没有答案