From 9e5baf4662f4b920350446c6aff8473a05a81ff8 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Fri, 2 Apr 2021 17:12:47 -0400 Subject: [PATCH] use WholeContainingBody instead of Sourceless When returning generic grpc errors from a provider, use WholeContainingBody so that callers can annotate the error with all the available contextual information. This can help troubleshoot problems by narrowing down problems to a particular configuration or specific resource instance. --- plugin/grpc_error.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugin/grpc_error.go b/plugin/grpc_error.go index 4875b576c..99ce8c8b8 100644 --- a/plugin/grpc_error.go +++ b/plugin/grpc_error.go @@ -45,26 +45,26 @@ func grpcErr(err error) (diags tfdiags.Diagnostics) { case codes.Unavailable: // This case is when the plugin has stopped running for some reason, // and is usually the result of a crash. - diags = diags.Append(tfdiags.Sourceless( + diags = diags.Append(tfdiags.WholeContainingBody( tfdiags.Error, "Plugin did not respond", fmt.Sprintf("The plugin encountered an error, and failed to respond to the %s call. "+ "The plugin logs may contain more details.", requestName), )) case codes.Canceled: - diags = diags.Append(tfdiags.Sourceless( + diags = diags.Append(tfdiags.WholeContainingBody( tfdiags.Error, "Request cancelled", fmt.Sprintf("The %s request was cancelled.", requestName), )) case codes.Unimplemented: - diags = diags.Append(tfdiags.Sourceless( + diags = diags.Append(tfdiags.WholeContainingBody( tfdiags.Error, "Unsupported plugin method", fmt.Sprintf("The %s method is not supported by this plugin.", requestName), )) default: - diags = diags.Append(tfdiags.Sourceless( + diags = diags.Append(tfdiags.WholeContainingBody( tfdiags.Error, "Plugin error", fmt.Sprintf("The plugin returned an unexpected error from %s: %v", requestName, err),