First merge from develop to main (WIP) #7
@@ -2,7 +2,6 @@ package exception
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log/slog"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// 12 chars len
|
// 12 chars len
|
||||||
@@ -60,7 +59,7 @@ func (self *Builder) Build() string {
|
|||||||
self.Original,
|
self.Original,
|
||||||
)
|
)
|
||||||
if self.Error != nil {
|
if self.Error != nil {
|
||||||
slog.Warn("Service exception", "id", errorCode, "err", self.Error)
|
ErrorHandler(self.Status, errorCode, self.Error)
|
||||||
}
|
}
|
||||||
return errorCode
|
return errorCode
|
||||||
}
|
}
|
||||||
|
|||||||
16
internal/exception/error.go
Normal file
16
internal/exception/error.go
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package exception
|
||||||
|
|
||||||
|
import "log/slog"
|
||||||
|
|
||||||
|
func ErrorHandler(status string, errorCode string, err error) {
|
||||||
|
switch status {
|
||||||
|
case StatusSuccess:
|
||||||
|
slog.Info("Service exception", "id", errorCode, "err", err)
|
||||||
|
case StatusUser:
|
||||||
|
slog.Warn("Service exception", "id", errorCode, "err", err)
|
||||||
|
case StatusServer:
|
||||||
|
slog.Error("Service exception", "id", errorCode, "err", err)
|
||||||
|
case StatusClient:
|
||||||
|
slog.Error("Service exception", "id", errorCode, "err", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user