Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

fixed error capitalization #979

Merged
merged 1 commit into from
Sep 17, 2020
Merged

Conversation

devang-gaur
Copy link
Contributor

fixes #637

pkg/terraform/executor.go Outdated Show resolved Hide resolved
knrt10
knrt10 previously approved these changes Sep 17, 2020
Copy link
Member

@knrt10 knrt10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1. Thanks @dev-gaur for your contribution

@knrt10 knrt10 requested a review from invidian September 17, 2020 07:53
Copy link
Member

@invidian invidian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution @dev-gaur. Before we can merge, please fix new sentences in the error messages, they should start with capital letter.

While we touch error messages, it would also be nice to re-phrase them properly, as we discuss, even though the decision is not finalized yet. See #953 and #883 for more details. TL;DR we would also remove failed, error etc keywords from error messages, leaving only for example checking Terraform version, as the fact that this is the error is implied. I posted 2 suggestions how it should look like.
However, this is of course optional for your work, as the changes presented in the PR are already a nice improvement :)

pkg/terraform/executor.go Outdated Show resolved Hide resolved
}

if n != 1 {
return fmt.Errorf("Parsing Terraform version failed")
return fmt.Errorf("parsing Terraform version failed")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return fmt.Errorf("parsing Terraform version failed")
return fmt.Errorf("parsing Terraform version")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@invidian now the string parsing Terraform version will look like a log message instead of an error message.
how about error occured while parsing Terraform version or unable to parse Terraform version?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, now that I think about it, this error message doesn't seem helpful at all. We could include expected format and parsed value in it.

Also, I look at the documentation of fmt.Sscanf right now and try to figure out in which case it returns error here.

Looking at https://golang.org/src/fmt/scan.go?s=4522:4597#L1181, I think it will always return err if n is different than number of operands passed. Would be good to have some unit tests for it :/

pkg/terraform/executor.go Outdated Show resolved Hide resolved
test/monitoring/components_alerts_test.go Outdated Show resolved Hide resolved
invidian
invidian previously approved these changes Sep 17, 2020
Copy link
Member

@invidian invidian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@invidian invidian requested a review from surajssd September 17, 2020 10:29
@invidian
Copy link
Member

Actually, before we close #637, we should also fix cli/cmd/cluster-destroy.go and cli/cmd/cluster-apply.go context logger messages, which are not capitalized at the moment.

@devang-gaur
Copy link
Contributor Author

@invidian do you mean contextLogger.Fatalf messages only ? or do you want to include contextLogger.Println messages as well?

@invidian
Copy link
Member

@dev-gaur it seems all Println occurences are already capitalized. I only see 2 lines with not capitalized Fatalf:

  • error applying cluster
  • error destroying cluster

@devang-gaur
Copy link
Contributor Author

@dev-gaur it seems all Println occurences are already capitalized. I only see 2 lines with not capitalized Fatalf:

  • error applying cluster
  • error destroying cluster

Aah I see. I thought you wanted to remove capitalization..

I have a confusion:
FatalF messages are technically exiting errors... So why do we want to capitalize them?

@invidian
Copy link
Member

FatalF messages are technically exiting errors... So why do we want to capitalize them?

Because those are the messages, which gets printed to the user, so they should be capitalized.

@devang-gaur
Copy link
Contributor Author

FatalF messages are technically exiting errors... So why do we want to capitalize them?

Because those are the messages, which gets printed to the user, so they should be capitalized.

Thanks for clarifying. Changes made.

Copy link
Member

@invidian invidian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks awesome now @dev-gaur. Thanks a lot for your effort!

@invidian invidian requested a review from knrt10 September 17, 2020 14:02
Copy link
Member

@knrt10 knrt10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1. Thanks again for the effort.

@knrt10 knrt10 merged commit 9fde1e9 into kinvolk:master Sep 17, 2020
@devang-gaur
Copy link
Contributor Author

even I learnt a bit about error formatting :)
thanks for attending to my PR so promptly

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make error capitalization consistent
3 participants