In Go I am using go-ethereum to read data from the ethereum smart contract. My smart contract is maintained with truffle.
I am trying to fetch candidate information based on candidate id. I have a modifier in the solidity that checks if given id exists or not as
/**
* Check if candidate exists
*/
modifier candidateExists(uint256 candidateId) {
require(candidates[candidateId].exists, "No Candidate.");
_;
}
Everything works perfectly fine if I pass valid candidateId. But exception occurs if candidates don't exists and revert. Following is the error recorded in ganache-cli console
(node:31528) UnhandledPromiseRejectionWarning: Error: nonce generation function failed or private key is invalid
at Object.t.sign (/usr/local/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:37:75864)
at Object.sign (/usr/local/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:37:64863)
at Object.t.ecsign (/usr/local/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:37:185991)
at e.sign (/usr/local/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:17:104733)
at e.sign (/usr/local/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:10:92594)
at e.t.hash (/usr/local/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:37:243491)
at e.u [as hash] (/usr/local/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:10:89447)
at c.combine (/usr/local/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:2:159323)
at new c (/usr/local/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:2:158990)
at Function.c.fromResults (/usr/local/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:2:160122)
at readyCall (/usr/local/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:17:120626)
(node:31528) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 26)
(node:31528) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.