refactor(processor): replace error message formatting with errors.New for better error handling

This commit is contained in:
2026-05-21 23:05:07 +08:00
parent 751e6afa83
commit de5c7f7eda
3 changed files with 76 additions and 42 deletions
+4 -3
View File
@@ -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)
}