diff --git a/backend/remote/backend.go b/backend/remote/backend.go index fc4040d39..c8bc867e7 100644 --- a/backend/remote/backend.go +++ b/backend/remote/backend.go @@ -657,11 +657,7 @@ func (b *Remote) Operation(ctx context.Context, op *backend.Operation) (*backend ) default: return nil, fmt.Errorf( - "%s\n\n"+ - "The configured \"remote\" backend encountered an unexpected error. Sometimes\n"+ - "this is caused by network connection problems, in which case you could retr\n"+ - "the command. If the issue persists please open a support ticket to get help\n"+ - "resolving the problem.", + "The configured \"remote\" backend encountered an unexpected error:\n\n%s", err, ) } diff --git a/backend/remote/backend_mock.go b/backend/remote/backend_mock.go index 8985dd0e3..214b242fd 100644 --- a/backend/remote/backend_mock.go +++ b/backend/remote/backend_mock.go @@ -948,6 +948,11 @@ func (m *mockWorkspaces) Create(ctx context.Context, organization string, option } func (m *mockWorkspaces) Read(ctx context.Context, organization, workspace string) (*tfe.Workspace, error) { + // custom error for TestRemote_plan500 in backend_plan_test.go + if workspace == "network-error" { + return nil, errors.New("I'm a little teacup") + } + w, ok := m.workspaceNames[workspace] if !ok { return nil, tfe.ErrResourceNotFound diff --git a/backend/remote/backend_plan_test.go b/backend/remote/backend_plan_test.go index 6b3d96753..3a6f868a1 100644 --- a/backend/remote/backend_plan_test.go +++ b/backend/remote/backend_plan_test.go @@ -855,3 +855,23 @@ func TestRemote_planWithRemoteError(t *testing.T) { t.Fatalf("expected plan error in output: %s", output) } } + +func TestRemote_planOtherError(t *testing.T) { + b, bCleanup := testBackendDefault(t) + defer bCleanup() + + op, configCleanup := testOperationPlan(t, "./testdata/plan") + defer configCleanup() + + op.Workspace = "network-error" // custom error response in backend_mock.go + + _, err := b.Operation(context.Background(), op) + if err == nil { + t.Errorf("expected error, got success") + } + + if !strings.Contains(err.Error(), + "The configured \"remote\" backend encountered an unexpected error:\n\nI'm a little teacup") { + t.Fatalf("expected error message, got: %s", err.Error()) + } +}