mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-06-18 18:16:26 +00:00
Use eris for error management
This commit is contained in:
@ -2,7 +2,6 @@ package certificate
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
goerrors "errors"
|
||||
"fmt"
|
||||
|
||||
"npm/internal/database"
|
||||
@ -11,6 +10,8 @@ import (
|
||||
"npm/internal/jobqueue"
|
||||
"npm/internal/logger"
|
||||
"npm/internal/model"
|
||||
|
||||
"github.com/rotisserie/eris"
|
||||
)
|
||||
|
||||
// GetByID finds a row by ID
|
||||
@ -23,7 +24,7 @@ func GetByID(id int) (Model, error) {
|
||||
// Create will create a row from this model
|
||||
func Create(certificate *Model) (int, error) {
|
||||
if certificate.ID != 0 {
|
||||
return 0, goerrors.New("Cannot create certificate when model already has an ID")
|
||||
return 0, eris.New("Cannot create certificate when model already has an ID")
|
||||
}
|
||||
|
||||
certificate.Touch(true)
|
||||
@ -77,7 +78,7 @@ func Create(certificate *Model) (int, error) {
|
||||
// Update will Update a Auth from this model
|
||||
func Update(certificate *Model) error {
|
||||
if certificate.ID == 0 {
|
||||
return goerrors.New("Cannot update certificate when model doesn't have an ID")
|
||||
return eris.New("Cannot update certificate when model doesn't have an ID")
|
||||
}
|
||||
|
||||
certificate.Touch(false)
|
||||
|
@ -1,7 +1,6 @@
|
||||
package certificate
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"regexp"
|
||||
@ -17,6 +16,8 @@ import (
|
||||
"npm/internal/logger"
|
||||
"npm/internal/types"
|
||||
"npm/internal/util"
|
||||
|
||||
"github.com/rotisserie/eris"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -90,15 +91,15 @@ func (m *Model) Save() error {
|
||||
var err error
|
||||
|
||||
if m.UserID == 0 {
|
||||
return fmt.Errorf("User ID must be specified")
|
||||
return eris.Errorf("User ID must be specified")
|
||||
}
|
||||
|
||||
if !m.Validate() {
|
||||
return fmt.Errorf("Certificate data is incorrect or incomplete for this type")
|
||||
return eris.Errorf("Certificate data is incorrect or incomplete for this type")
|
||||
}
|
||||
|
||||
if !m.ValidateWildcardSupport() {
|
||||
return fmt.Errorf("Cannot use Wildcard domains with this CA")
|
||||
return eris.Errorf("Cannot use Wildcard domains with this CA")
|
||||
}
|
||||
|
||||
m.setDefaultStatus()
|
||||
@ -215,7 +216,7 @@ func (m *Model) Expand(items []string) error {
|
||||
// Returns: (key, fullchain, certFolder)
|
||||
func (m *Model) GetCertificateLocations() (string, string, string) {
|
||||
if m.ID == 0 {
|
||||
logger.Error("GetCertificateLocationsError", errors.New("GetCertificateLocations called before certificate was saved"))
|
||||
logger.Error("GetCertificateLocationsError", eris.New("GetCertificateLocations called before certificate was saved"))
|
||||
return "", "", ""
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user