refactor(processor): replace error message formatting with errors.New for better error handling
This commit is contained in:
@@ -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