From 97e9d02c084d7ed2a97cbef46ca0214a25e32751 Mon Sep 17 00:00:00 2001 From: Ethen Pociask Date: Wed, 2 Oct 2024 15:49:34 -0700 Subject: [PATCH] chore: Only return commitment on PUT for OP Generic and Simple commitment modes- rm error file --- utils/error.go | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 utils/error.go diff --git a/utils/error.go b/utils/error.go deleted file mode 100644 index 802ee79..0000000 --- a/utils/error.go +++ /dev/null @@ -1,46 +0,0 @@ -package utils - -import ( - "fmt" - - "github.com/google/uuid" -) - -type APIError struct { - InternalMsg string `json:"internal_msg"` - ExternalMsg string `json:"user_msg"` - StatusCode int `json:"status_code"` - UUID string `json:"uuid"` -} - -// Error serializes the error to json structured string -func (e *APIError) Error() string { - return fmt.Sprintf(`"internal_msg": "%s", "user_msg": "%s", "status_code": %d, "uuid": "%s"}`, - e.InternalMsg, e.ExternalMsg, e.StatusCode, e.UUID) -} - -func (e *APIError) SerializeResponse() []byte { - if e.ExternalMsg == "" { - e.ExternalMsg = e.InternalMsg - } - - return []byte(fmt.Sprintf(`{"error_msg": "%s", "status_code": %d, "uuid": "%s"}`, - e.ExternalMsg, e.StatusCode, e.UUID)) -} - -func (e *APIError) WithExternalMsg(msg string) *APIError { - e.ExternalMsg = msg - return e -} - -func (e *APIError) WithStatusCode(code int) *APIError { - e.StatusCode = code - return e -} - -func NewError(internalMsg string) *APIError { - return &APIError{ - InternalMsg: internalMsg, - UUID: uuid.NewString(), - } -}