Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #123 from rafiss/max-retry-error
Make max retry error show correct message
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2022 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package crdb | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func TestMaxRetriesExceededError(t *testing.T) { | ||
origError := fmt.Errorf("root error") | ||
err := newMaxRetriesExceededError(origError, 10) | ||
if !strings.HasPrefix(err.Error(), "retrying txn failed after 10 attempts.") { | ||
t.Fatalf("expected txn retry error message") | ||
} | ||
if !errors.Is(err, origError) { | ||
t.Fatal("expected to find root error cause") | ||
} | ||
} |