Skip to content

Commit

Permalink
Merge pull request #401 from 88labs/feature/cerrors_already_exists
Browse files Browse the repository at this point in the history
feat(cerrors): add AlreadyExists
  • Loading branch information
KamikazeZirou authored Dec 28, 2023
2 parents fdb4116 + 3d3a4f9 commit a5217fb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cerrors/cerrors.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const (
UnavailableErr
ResourceExhaustedErr
Canceled
AlreadyExists
)

func (e ErrorCode) String() string {
Expand All @@ -45,6 +46,8 @@ func (e ErrorCode) String() string {
return "ResourceExhaustedErr"
case Canceled:
return "Canceled"
case AlreadyExists:
return "AlreadyExists"
default:
return "UnknownErr"
}
Expand Down Expand Up @@ -75,7 +78,8 @@ func defaultErrorLevel(code ErrorCode) ErrorLevel {
ParameterErr,
ResourceExhaustedErr,
FailedPreconditionErr,
Canceled:
Canceled,
AlreadyExists:
return ErrorLevelWarn
case UnknownErr,
UnimplementedErr,
Expand Down
7 changes: 7 additions & 0 deletions cerrors/cerrors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,13 @@ func Test_ErrorCode_String(t *testing.T) {
},
want: "Canceled",
},
{
name: "AlreadyExists",
args: args{
code: AlreadyExists,
},
want: "AlreadyExists",
},
{
name: "不正値",
args: args{
Expand Down

0 comments on commit a5217fb

Please sign in to comment.