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 host
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
goerrors "errors"
|
||||
"fmt"
|
||||
|
||||
"npm/internal/database"
|
||||
@ -10,6 +9,8 @@ import (
|
||||
"npm/internal/errors"
|
||||
"npm/internal/logger"
|
||||
"npm/internal/model"
|
||||
|
||||
"github.com/rotisserie/eris"
|
||||
)
|
||||
|
||||
// GetByID finds a Host by ID
|
||||
@ -22,7 +23,7 @@ func GetByID(id int) (Model, error) {
|
||||
// create will create a Host from this model
|
||||
func create(host *Model) (int, error) {
|
||||
if host.ID != 0 {
|
||||
return 0, goerrors.New("Cannot create host when model already has an ID")
|
||||
return 0, eris.New("Cannot create host when model already has an ID")
|
||||
}
|
||||
|
||||
host.Touch(true)
|
||||
@ -102,7 +103,7 @@ func create(host *Model) (int, error) {
|
||||
// update will Update a Host from this model
|
||||
func update(host *Model) error {
|
||||
if host.ID == 0 {
|
||||
return goerrors.New("Cannot update host when model doesn't have an ID")
|
||||
return eris.New("Cannot update host when model doesn't have an ID")
|
||||
}
|
||||
|
||||
host.Touch(false)
|
||||
|
@ -12,6 +12,8 @@ import (
|
||||
"npm/internal/status"
|
||||
"npm/internal/types"
|
||||
"npm/internal/util"
|
||||
|
||||
"github.com/rotisserie/eris"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -87,7 +89,7 @@ func (m *Model) Save(skipConfiguration bool) 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 !skipConfiguration {
|
||||
|
Reference in New Issue
Block a user