enhance: replace error handling with cosy wrapper for nginx reload and test failures

This commit is contained in:
Jacky 2025-04-18 08:06:34 +00:00
parent c5e80fb98a
commit d789326230
No known key found for this signature in database
GPG key ID: 215C21B10DF38B4D
14 changed files with 57 additions and 43 deletions

View file

@ -11,6 +11,7 @@ import (
"github.com/0xJacky/Nginx-UI/internal/nginx"
"github.com/0xJacky/Nginx-UI/internal/notification"
"github.com/go-resty/resty/v2"
"github.com/uozi-tech/cosy"
"github.com/uozi-tech/cosy/logger"
)
@ -37,12 +38,12 @@ func Enable(name string) (err error) {
output := nginx.TestConf()
if nginx.GetLogLevel(output) > nginx.Warn {
_ = os.Remove(enabledConfigFilePath)
return fmt.Errorf("%s", output)
return cosy.WrapErrorWithParams(ErrNginxTestFailed, output)
}
output = nginx.Reload()
if nginx.GetLogLevel(output) > nginx.Warn {
return fmt.Errorf("%s", output)
return cosy.WrapErrorWithParams(ErrNginxReloadFailed, output)
}
go syncEnable(name)