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.
This commit is contained in:
parent
265b5106ca
commit
9e5baf4662
|
@ -45,26 +45,26 @@ func grpcErr(err error) (diags tfdiags.Diagnostics) {
|
||||||
case codes.Unavailable:
|
case codes.Unavailable:
|
||||||
// This case is when the plugin has stopped running for some reason,
|
// This case is when the plugin has stopped running for some reason,
|
||||||
// and is usually the result of a crash.
|
// and is usually the result of a crash.
|
||||||
diags = diags.Append(tfdiags.Sourceless(
|
diags = diags.Append(tfdiags.WholeContainingBody(
|
||||||
tfdiags.Error,
|
tfdiags.Error,
|
||||||
"Plugin did not respond",
|
"Plugin did not respond",
|
||||||
fmt.Sprintf("The plugin encountered an error, and failed to respond to the %s call. "+
|
fmt.Sprintf("The plugin encountered an error, and failed to respond to the %s call. "+
|
||||||
"The plugin logs may contain more details.", requestName),
|
"The plugin logs may contain more details.", requestName),
|
||||||
))
|
))
|
||||||
case codes.Canceled:
|
case codes.Canceled:
|
||||||
diags = diags.Append(tfdiags.Sourceless(
|
diags = diags.Append(tfdiags.WholeContainingBody(
|
||||||
tfdiags.Error,
|
tfdiags.Error,
|
||||||
"Request cancelled",
|
"Request cancelled",
|
||||||
fmt.Sprintf("The %s request was cancelled.", requestName),
|
fmt.Sprintf("The %s request was cancelled.", requestName),
|
||||||
))
|
))
|
||||||
case codes.Unimplemented:
|
case codes.Unimplemented:
|
||||||
diags = diags.Append(tfdiags.Sourceless(
|
diags = diags.Append(tfdiags.WholeContainingBody(
|
||||||
tfdiags.Error,
|
tfdiags.Error,
|
||||||
"Unsupported plugin method",
|
"Unsupported plugin method",
|
||||||
fmt.Sprintf("The %s method is not supported by this plugin.", requestName),
|
fmt.Sprintf("The %s method is not supported by this plugin.", requestName),
|
||||||
))
|
))
|
||||||
default:
|
default:
|
||||||
diags = diags.Append(tfdiags.Sourceless(
|
diags = diags.Append(tfdiags.WholeContainingBody(
|
||||||
tfdiags.Error,
|
tfdiags.Error,
|
||||||
"Plugin error",
|
"Plugin error",
|
||||||
fmt.Sprintf("The plugin returned an unexpected error from %s: %v", requestName, err),
|
fmt.Sprintf("The plugin returned an unexpected error from %s: %v", requestName, err),
|
||||||
|
|
Loading…
Reference in New Issue