enhance(wip): error handle

This commit is contained in:
Jacky 2025-01-24 16:37:45 +08:00
parent 3f95ae5d90
commit 650196d06a
No known key found for this signature in database
GPG key ID: 215C21B10DF38B4D
93 changed files with 5228 additions and 3738 deletions

View file

@ -1,7 +1,6 @@
package cert
import (
"fmt"
"github.com/0xJacky/Nginx-UI/internal/helper"
"github.com/0xJacky/Nginx-UI/internal/nginx"
"os"
@ -22,13 +21,11 @@ func (c *Content) WriteFile() (err error) {
nginxConfPath := nginx.GetConfPath()
if !helper.IsUnderDirectory(c.SSLCertificatePath, nginxConfPath) {
return fmt.Errorf("ssl_certificate_path: %s is not under the nginx conf path: %s",
c.SSLCertificatePath, nginxConfPath)
return e.NewWithParams(50006, ErrPathIsNotUnderTheNginxConfDir.Error(), c.SSLCertificatePath, nginxConfPath)
}
if !helper.IsUnderDirectory(c.SSLCertificateKeyPath, nginxConfPath) {
return fmt.Errorf("ssl_certificate_key_path: %s is not under the nginx conf path: %s",
c.SSLCertificateKeyPath, nginxConfPath)
return e.NewWithParams(50006, ErrPathIsNotUnderTheNginxConfDir.Error(), c.SSLCertificateKeyPath, nginxConfPath)
}
// MkdirAll creates a directory named path, along with any necessary parents,