-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve error handling when smart contract is not found #586
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…actImports before throwing error to provide more specific error message
…ract in build directory The error message displayed when failing to find the specified smart contract in the build directory was not clear enough. This commit improves the error message by providing more detailed instructions to the user. The error message now asks the user to confirm that their config.json file contains the name of the smart contract they want to deploy to the specified alias. Additionally, it reminds the user to check that they have exported their smart contract class using a named export.
…in build directory
…ing if contractName exists
…art contract is not found in build directory
…ot found in build directory and propogate node error otherwise. The previous implementation of importing the smart contract class to deploy from the user's file was complex and difficult to understand. This commit refactors the logic to improve readability and error handling. - The variable `smartContractImports` is now declared and assigned directly in the try block, removing the need for a separate declaration outside the try block. - The import path for the smart contract file is now constructed before the try block, simplifying the code. - The error handling for importing the smart contract class has been improved. If the named export is not found, an error message is logged and the process exits with a non-zero status code. These changes make the code more maintainable and easier to understand.
shimkiv
approved these changes
Feb 16, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with comment.
…d in build directory.
…not found in build directory." This reverts commit e7c3d38.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.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.