-
-
Notifications
You must be signed in to change notification settings - Fork 112
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
Emit Friendly Message When Component Docs Not Found #1032
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughThe pull request enhances the error handling logic in the Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
cmd/docs.go (1)
73-79
: Consider consolidating README error messages for consistency.Since we're streamlining error messages, we could also simplify this error handling block to match the same pattern:
if _, err := os.Stat(readmePath); err != nil { - if os.IsNotExist(err) { - u.LogErrorAndExit(fmt.Errorf("No README found for component: %s", info.Component)) - } else { - u.LogErrorAndExit(fmt.Errorf("Component %s not found", info.Component)) - } + u.LogErrorAndExit(fmt.Errorf("No README found for component: %s", info.Component)) }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
cmd/docs.go
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Build (windows-latest, windows)
- GitHub Check: Summary
🔇 Additional comments (1)
cmd/docs.go (1)
68-70
: LGTM! Clean consolidation of error handling.The combined error check simplifies the control flow while maintaining clear error messaging. This aligns well with the PR's goal of providing a more consistent user experience.
Please add a test case similar to this one: https://github.com/cloudposse/atmos/blob/main/tests/test-cases/core.yaml#L67-L81 that checks for non-zero exit code, and a helpful error message. |
@@ -83,7 +80,7 @@ var docsCmd = &cobra.Command{ | |||
|
|||
readmeContent, err := os.ReadFile(readmePath) | |||
if err != nil { | |||
u.LogErrorAndExit(err) | |||
u.LogErrorAndExit(fmt.Errorf("Loading README file for component: %s", info.Component)) |
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.
do we want to show the actual err
here?
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.
@aknysh is correct, this doesn't achieve the desired outcome. We handle errors today, but it's not friendly.
Here's what we want:
- If the component folder is not found, say "Component not found"
- If the component lacks a README.md, say "Documentation is missing for the component asd. Consider adding a
README.md
to provide more context and details."
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.
Let’s use l.Debug to emit the actual error, and print a friendly one here.
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.
That would be useful
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.
Also, use l.Fatal instead of u.LogErrorAndExit (deprecated after moving to new logger)
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.
please see comments
what
why
references
DEV-2718
Summary by CodeRabbit