o1-labs / zkapp-cli

CLI to create a zkApp (zero-knowledge app) for Mina Protocol
https://docs.minaprotocol.com/zkapps/how-to-write-a-zkapp
Apache License 2.0
114 stars 43 forks source link

Improve error handling when smart contract is not found #586

Closed ymekuria closed 7 months ago

ymekuria commented 7 months ago

Description

Closes #329

Previously when an error occurred while importing a smart contract from the build directory during the deploy step, the zkApp CLI would swallow the error and display the message.

  Failed to find the "Add" smart contract in your build directory.
  Please confirm that your config.json contains the name of the smart contract that you desire to deploy to this deploy alias.

There are many different errors that can happen while importing a smart contract. This caused a poor DX, and made it extremely hard for user to find the source of the real errors.

Solution

This PR improves the error handling for zk deploy when a smart contract is not found in the build directory. A custom error message is only shown to a user if the smart contract is not found in the build directory. All other errors are thrown otherwise, enabling users to identify the cause of the error.

Additionaly, the custom error message was improved to help a user troubleshoot the problem when a contract is not found in the build directory.