-
Notifications
You must be signed in to change notification settings - Fork 38
Add New...f constructors for all service errors #221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ package serviceerror | |
|
|
||
| import ( | ||
| "errors" | ||
| "fmt" | ||
|
|
||
| "go.temporal.io/api/errordetails/v1" | ||
| "google.golang.org/grpc/codes" | ||
|
|
@@ -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 { | ||
|
||
| return &MultiOperationExecution{Message: fmt.Sprintf(format, args...), errs: errs} | ||
| } | ||
|
|
||
| // Error returns string message. | ||
| func (e *MultiOperationExecution) Error() string { | ||
| return e.Message | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 { | ||
|
||
| 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 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 { | ||
|
||
| 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 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 { | ||
|
||
| 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(). | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 { | ||
|
||
| return &NewerBuildExists{ | ||
| Message: fmt.Sprintf(format, args...), | ||
| DefaultBuildID: defaultBuildID, | ||
| } | ||
| } | ||
|
|
||
| // Error returns string message. | ||
| func (e *NewerBuildExists) Error() string { | ||
| return e.Message | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and ideally the non-f one should be renamed too