Skip to content
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 Diagnostics consistency #213

Merged
merged 6 commits into from
Jun 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Use a constant for the report message
Uses a constant for the report message so we can call it where needed.
mitchnielsen committed Jun 13, 2024
commit 9fee4862fde953ac8cd073523f27704135749483
6 changes: 4 additions & 2 deletions internal/provider/helpers/diagnostics.go
Original file line number Diff line number Diff line change
@@ -6,7 +6,9 @@ import (
"github.com/hashicorp/terraform-plugin-framework/diag"
)

// https://developer.hashicorp.com/terraform/plugin/framework/diagnostics#custom-diagnostics-types
const (
reportMessage = "Please report this issue to the provider developers."
)

// CreateClientErrorDiagnostic returns an error diagnostic for when one of the
// HTTP clients failed to be instantiated.
@@ -15,7 +17,7 @@ import (
func CreateClientErrorDiagnostic(clientName string, err error) diag.Diagnostic {
return diag.NewErrorDiagnostic(
fmt.Sprintf("Error creating %s client", clientName),
fmt.Sprintf("Could not create %s client, due to error: %s. If you believe this to be a bug in the provider, please report this to the maintainers.", clientName, err.Error()),
fmt.Sprintf("Could not create %s client, due to error: %s. %s", clientName, err.Error(), reportMessage),
)
}