refactor(processor): replace error message formatting with errors.New for better error handling
This commit is contained in:
1 parent
751e6afa83
commit
de5c7f7eda
3 files changed
+76
-42
No files matched your search
@@ -1,12 +1,13 @@
|
||||
package errorHandle
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"time"
|
||||
|
||||
"Watchdog_Linux-systemd/postLog"
|
||||
"Watchdog_Linux-systemd/global"
|
||||
"Watchdog_Linux-systemd/postLog"
|
||||
)
|
||||
|
||||
type ServiceStatusChecker func(serviceName string) bool
|
||||
@@ -35,5 +36,5 @@ func HandleErrorProcess(serviceName string, isServiceRunning ServiceStatusChecke
|
||||
serviceControl.ErrorType = "restart"
|
||||
serviceControl.ErrorMsg = fmt.Sprintf("Failed to recover service '%s', retry count: %d", serviceName, serviceControl.RetryCount)
|
||||
serviceControl.ErrorTime = time.Now()
|
||||
return fmt.Errorf(serviceControl.ErrorMsg)
|
||||
}
|
||||
return errors.New(serviceControl.ErrorMsg)
|
||||
}
|
||||
Reference in new issue
Block a user