I write a solidty code and also a custom error like this:

error TestObject__IndexNotFound();

function getProductChain(uint256 index) public view returns(SupplyChain memory){
    if (index > (counter - 1) || index < 0){
        revert TestObject__IndexNotFound();
    SupplyChain memory spChain = supplyChain[index];
    return spChain;

But when i catch this error, the name of this error doesn't show:

     const transactionResponse = await contract.getProductChain(index);

Instead, it just writes 'revert' with no reason!. I can write require with string but I want to use error and revert. Last time when I used ethers and hardhat (node), the reverted error was shown in my console. But now it doesn't. I used ethers and ganache this time:

Error: missing revert data in call exception; Transaction reverted without a reason 


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.