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 upstreamserver
|
||||
|
||||
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 Upstream Server by ID
|
||||
@ -34,7 +35,7 @@ func GetByUpstreamID(upstreamID int) ([]Model, error) {
|
||||
// create will create a Upstream Server from this model
|
||||
func create(u *Model) (int, error) {
|
||||
if u.ID != 0 {
|
||||
return 0, goerrors.New("Cannot create upstream server when model already has an ID")
|
||||
return 0, eris.New("Cannot create upstream server when model already has an ID")
|
||||
}
|
||||
|
||||
u.Touch(true)
|
||||
@ -82,7 +83,7 @@ func create(u *Model) (int, error) {
|
||||
// update will Update a Upstream from this model
|
||||
func update(u *Model) error {
|
||||
if u.ID == 0 {
|
||||
return goerrors.New("Cannot update upstream server when model doesn't have an ID")
|
||||
return eris.New("Cannot update upstream server when model doesn't have an ID")
|
||||
}
|
||||
|
||||
u.Touch(false)
|
||||
|
@ -6,6 +6,8 @@ import (
|
||||
|
||||
"npm/internal/database"
|
||||
"npm/internal/types"
|
||||
|
||||
"github.com/rotisserie/eris"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -53,7 +55,7 @@ func (m *Model) Save() error {
|
||||
var err error
|
||||
|
||||
if m.UpstreamID == 0 {
|
||||
return fmt.Errorf("Upstream ID must be specified")
|
||||
return eris.Errorf("Upstream ID must be specified")
|
||||
}
|
||||
|
||||
if m.ID == 0 {
|
||||
|
Reference in New Issue
Block a user