Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions serviceerror/already_exists.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package serviceerror

import (
"fmt"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
Expand All @@ -20,6 +21,13 @@ func NewAlreadyExist(message string) error {
}
}

// NewAlreadyExistf returns new AlreadyExists error with formatted message.
func NewAlreadyExistf(format string, args ...interface{}) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// NewAlreadyExistf returns new AlreadyExists error with formatted message.
func NewAlreadyExistf(format string, args ...interface{}) error {
// NewAlreadyExistsf returns new AlreadyExists error with formatted message.
func NewAlreadyExistsf(format string, args ...interface{}) error {

and ideally the non-f one should be renamed too

return &AlreadyExists{
Message: fmt.Sprintf(format, args...),
}
}

// Error returns string message.
func (e *AlreadyExists) Error() string {
return e.Message
Expand Down
8 changes: 8 additions & 0 deletions serviceerror/canceled.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package serviceerror

import (
"fmt"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
Expand All @@ -20,6 +21,13 @@ func NewCanceled(message string) error {
}
}

// NewCanceledf returns new Canceled error with formatted message.
func NewCanceledf(format string, args ...interface{}) error {
return &Canceled{
Message: fmt.Sprintf(format, args...),
}
}

// Error returns string message.
func (e *Canceled) Error() string {
return e.Message
Expand Down
8 changes: 8 additions & 0 deletions serviceerror/cancellation_already_requested.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package serviceerror

import (
"fmt"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

Expand All @@ -22,6 +23,13 @@ func NewCancellationAlreadyRequested(message string) error {
}
}

// NewCancellationAlreadyRequestedf returns new CancellationAlreadyRequested error with formatted message.
func NewCancellationAlreadyRequestedf(format string, args ...interface{}) error {
return &CancellationAlreadyRequested{
Message: fmt.Sprintf(format, args...),
}
}

// Error returns string message.
func (e *CancellationAlreadyRequested) Error() string {
return e.Message
Expand Down
10 changes: 10 additions & 0 deletions serviceerror/client_version_not_supported.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ func NewClientVersionNotSupported(clientVersion, clientName, supportedVersions s
}
}

// NewClientVersionNotSupportedf returns new ClientVersionNotSupported error with formatted message.
func NewClientVersionNotSupportedf(clientVersion, clientName, supportedVersions, format string, args ...interface{}) error {
return &ClientVersionNotSupported{
Message: fmt.Sprintf(format, args...),
ClientVersion: clientVersion,
ClientName: clientName,
SupportedVersions: supportedVersions,
}
}

// Error returns string message.
func (e *ClientVersionNotSupported) Error() string {
return e.Message
Expand Down
8 changes: 8 additions & 0 deletions serviceerror/data_loss.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package serviceerror

import (
"fmt"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
Expand All @@ -20,6 +21,13 @@ func NewDataLoss(message string) error {
}
}

// NewDataLossf returns new DataLoss error with formatted message.
func NewDataLossf(format string, args ...interface{}) error {
return &DataLoss{
Message: fmt.Sprintf(format, args...),
}
}

// Error returns string message.
func (e *DataLoss) Error() string {
return e.Message
Expand Down
8 changes: 8 additions & 0 deletions serviceerror/deadline_exceeded.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package serviceerror

import (
"fmt"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
Expand All @@ -20,6 +21,13 @@ func NewDeadlineExceeded(message string) error {
}
}

// NewDeadlineExceededf returns new DeadlineExceeded error with formatted message.
func NewDeadlineExceededf(format string, args ...interface{}) error {
return &DeadlineExceeded{
Message: fmt.Sprintf(format, args...),
}
}

// Error returns string message.
func (e *DeadlineExceeded) Error() string {
return e.Message
Expand Down
8 changes: 8 additions & 0 deletions serviceerror/failed_precondition.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package serviceerror

import (
"fmt"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
Expand All @@ -20,6 +21,13 @@ func NewFailedPrecondition(message string) error {
}
}

// NewFailedPreconditionf returns new FailedPrecondition error with formatted message.
func NewFailedPreconditionf(format string, args ...interface{}) error {
return &FailedPrecondition{
Message: fmt.Sprintf(format, args...),
}
}

// Error returns string message.
func (e *FailedPrecondition) Error() string {
return e.Message
Expand Down
8 changes: 8 additions & 0 deletions serviceerror/internal.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package serviceerror

import (
"fmt"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
Expand All @@ -20,6 +21,13 @@ func NewInternal(message string) error {
}
}

// NewInternalf returns new Internal error with formatted message.
func NewInternalf(format string, args ...interface{}) error {
return &Internal{
Message: fmt.Sprintf(format, args...),
}
}

// Error returns string message.
func (e *Internal) Error() string {
return e.Message
Expand Down
8 changes: 8 additions & 0 deletions serviceerror/invalid_argument.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package serviceerror

import (
"fmt"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
Expand All @@ -20,6 +21,13 @@ func NewInvalidArgument(message string) error {
}
}

// NewInvalidArgumentf returns new InvalidArgument error with formatted message.
func NewInvalidArgumentf(format string, args ...interface{}) error {
return &InvalidArgument{
Message: fmt.Sprintf(format, args...),
}
}

// Error returns string message.
func (e *InvalidArgument) Error() string {
return e.Message
Expand Down
6 changes: 6 additions & 0 deletions serviceerror/multi_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package serviceerror

import (
"errors"
"fmt"

"go.temporal.io/api/errordetails/v1"
"google.golang.org/grpc/codes"
Expand All @@ -20,6 +21,11 @@ func NewMultiOperationExecution(message string, errs []error) error {
return &MultiOperationExecution{Message: message, errs: errs}
}

// NewMultiOperationExecutionf returns a new MultiOperationExecution error with formatted message.
func NewMultiOperationExecutionf(format string, errs []error, args ...interface{}) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weird to have format and args separated, how about switching the order?

return &MultiOperationExecution{Message: fmt.Sprintf(format, args...), errs: errs}
}

// Error returns string message.
func (e *MultiOperationExecution) Error() string {
return e.Message
Expand Down
8 changes: 8 additions & 0 deletions serviceerror/multi_op_aborted.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package serviceerror

import (
"fmt"
failurepb "go.temporal.io/api/failure/v1"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
Expand All @@ -19,6 +20,13 @@ func NewMultiOperationAborted(message string) error {
}
}

// NewMultiOperationAbortedf returns MultiOperationAborted with formatted message.
func NewMultiOperationAbortedf(format string, args ...interface{}) error {
return &MultiOperationAborted{
Message: fmt.Sprintf(format, args...),
}
}

// Error returns string message.
func (e MultiOperationAborted) Error() string {
return e.Message
Expand Down
8 changes: 8 additions & 0 deletions serviceerror/namespace_already_exists.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package serviceerror

import (
"fmt"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

Expand All @@ -22,6 +23,13 @@ func NewNamespaceAlreadyExists(message string) error {
}
}

// NewNamespaceAlreadyExistsf returns new NamespaceAlreadyExists error with formatted message.
func NewNamespaceAlreadyExistsf(format string, args ...interface{}) error {
return &NamespaceAlreadyExists{
Message: fmt.Sprintf(format, args...),
}
}

// Error returns string message.
func (e *NamespaceAlreadyExists) Error() string {
return e.Message
Expand Down
10 changes: 10 additions & 0 deletions serviceerror/namespace_invalid_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ func NewNamespaceInvalidState(namespace string, state enumspb.NamespaceState, al
}
}

// NewNamespaceInvalidStatef returns new NamespaceInvalidState error with formatted message.
func NewNamespaceInvalidStatef(namespace string, state enumspb.NamespaceState, allowedStates []enumspb.NamespaceState, format string, args ...interface{}) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really need this one? the main constructor does a good job with messages...

return &NamespaceInvalidState{
Message: fmt.Sprintf(format, args...),
Namespace: namespace,
State: state,
AllowedStates: allowedStates,
}
}

// Error returns string message.
func (e *NamespaceInvalidState) Error() string {
return e.Message
Expand Down
10 changes: 10 additions & 0 deletions serviceerror/namespace_not_active.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ func NewNamespaceNotActive(namespace, currentCluster, activeCluster string) erro
}
}

// NewNamespaceNotActivef returns new NamespaceNotActive error with formatted message.
func NewNamespaceNotActivef(namespace, currentCluster, activeCluster, format string, args ...interface{}) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here...

return &NamespaceNotActive{
Message: fmt.Sprintf(format, args...),
Namespace: namespace,
CurrentCluster: currentCluster,
ActiveCluster: activeCluster,
}
}

// Error returns string message.
func (e *NamespaceNotActive) Error() string {
return e.Message
Expand Down
8 changes: 8 additions & 0 deletions serviceerror/namespace_not_found.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ func NewNamespaceNotFound(namespace string) error {
}
}

// NewNamespaceNotFoundf returns new NamespaceNotFound error with formatted message.
func NewNamespaceNotFoundf(namespace, format string, args ...interface{}) error {
return &NamespaceNotFound{
Message: fmt.Sprintf(format, args...),
Namespace: namespace,
}
}

// Error returns string message.
func (e *NamespaceNotFound) Error() string {
return e.Message
Expand Down
8 changes: 8 additions & 0 deletions serviceerror/namespace_unavailable.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ func NewNamespaceUnavailable(namespace string) error {
}
}

// NewNamespaceUnavailablef returns new NamespaceUnavailable error with formatted message.
func NewNamespaceUnavailablef(namespace, format string, args ...interface{}) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this probably shouldn't exist, NamespaceUnavailable has no Message field

return &NamespaceUnavailable{
Namespace: namespace,
st: status.New(codes.Unavailable, fmt.Sprintf(format, args...)),
}
}

// Error returns string message.
func (e *NamespaceUnavailable) Error() string {
// No need to do a nil check, that's handled in Message().
Expand Down
8 changes: 8 additions & 0 deletions serviceerror/newer_build_exists.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ func NewNewerBuildExists(defaultBuildID string) error {
}
}

// NewNewerBuildExistsf returns new NewerBuildExists error with formatted message.
func NewNewerBuildExistsf(defaultBuildID, format string, args ...interface{}) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe not needed?

return &NewerBuildExists{
Message: fmt.Sprintf(format, args...),
DefaultBuildID: defaultBuildID,
}
}

// Error returns string message.
func (e *NewerBuildExists) Error() string {
return e.Message
Expand Down
8 changes: 8 additions & 0 deletions serviceerror/not_found.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package serviceerror

import (
"fmt"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

Expand All @@ -24,6 +25,13 @@ func NewNotFound(message string) error {
}
}

// NewNotFoundf returns new NotFound error with formatted message.
func NewNotFoundf(format string, args ...interface{}) error {
return &NotFound{
Message: fmt.Sprintf(format, args...),
}
}

// Error returns string message.
func (e *NotFound) Error() string {
return e.Message
Expand Down
9 changes: 9 additions & 0 deletions serviceerror/permission_denied.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package serviceerror

import (
"fmt"
"go.temporal.io/api/errordetails/v1"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
Expand All @@ -23,6 +24,14 @@ func NewPermissionDenied(message, reason string) error {
}
}

// NewPermissionDeniedf returns new PermissionDenied error with formatted message.
func NewPermissionDeniedf(reason, format string, args ...interface{}) error {
return &PermissionDenied{
Message: fmt.Sprintf(format, args...),
Reason: reason,
}
}

// Error returns string message.
func (e *PermissionDenied) Error() string {
return e.Message
Expand Down
Loading