refactor mw example

This commit is contained in:
dpurbosakti
2025-08-21 16:24:48 +07:00
parent 5c716eb269
commit 7a032ff518
5 changed files with 324 additions and 153 deletions
+8
View File
@@ -0,0 +1,8 @@
package usecasehelper
type MWType string
const (
MWTPre MWType = "Pre"
MWTPost MWType = "Post"
)
+8
View File
@@ -3,6 +3,7 @@ package usecasehelper
import (
"errors"
"fmt"
"strings"
pl "simrs-vx/pkg/logger"
@@ -46,3 +47,10 @@ func HandleReadError(err error, event *pl.Event, itemType string, id interface{}
return pl.SetLogError(*event, nil)
}
func GetMiddlewareErrorCode(mwType MWType) string {
if strings.Contains(string(mwType), "Pre") {
return "MW_PRE_FAILED"
}
return "MW_POST_FAILED"
}