Another question. Looks like there is a new error ...
# atmos-dev
c
Another question. Looks like there is a new error print command
u.PrintErrorMarkdownAndExit
though it was only changed on two lines. Is there a reason we did not use it for other errors?
Copy code
// Construct the full path to the Terraform component by combining the Atmos base path, Terraform base path, and component name
			componentPath := filepath.Join(atmosConfig.BasePath, atmosConfig.Components.Terraform.BasePath, info.Component)
			componentPathExists, err := u.IsDirectory(componentPath)
			if err != nil {
				u.PrintErrorMarkdownAndExit("", err, "")
			}
			if !componentPathExists {
				u.PrintErrorMarkdownAndExit("", fmt.Errorf("Component `%s` not found in path: `%s`", info.Component, componentPath), "")
			}

			readmePath := filepath.Join(componentPath, "README.md")
			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))
				}
			}

			readmeContent, err := os.ReadFile(readmePath)
			if err != nil {
				u.LogErrorAndExit(err)
			}
a
PrintErrorMarkdownAndExit
was introduced recently and the code was not updated to use it (not sure why it was not updated in the same file, it's an omission, but it would prob take a separate PR to update all the legacy invocations)
c
@Andriy Knysh (Cloud Posse) - So I can update all the error calls with the new command in this PR, correct? https://github.com/cloudposse/atmos/pull/1032
a
yes, I'd suggest you use the new function in the code you are changing (not sure if it's feasible to change it everywhere w/o testing all of it)
👍 1
c
Thank @Andriy Knysh (Cloud Posse)
e
@Shubham Tholiya
s
This function was introduced to display good looking markdown errors in TUI This function should not be used for errors that are considered log but should be used for errors that should be displayed to the user Example: parameter/arg invalid, Permission issue thatt can not let the command run, etc. Should we use this function? Yes. Everywhere? Yes, as long as the code is well structured enough to provide useful error messages to the customer
c
Thank you 🙏