Use eris for error management

This commit is contained in:
Jamie Curnow committed 2023-02-24 17:19:07 +10:00
1 parent 80315bd50e
commit c288886fd4
44 files changed
+173 -128

No files matched your search

+4 -3
View File
@@ -2,7 +2,6 @@ package stream
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 auth by ID
@@ -22,7 +23,7 @@ func GetByID(id int) (Model, error) {
// Create will create a Auth from this model
func Create(host *Model) (int, error) {
if host.ID != 0 {
return 0, goerrors.New("Cannot create stream when model already has an ID")
return 0, eris.New("Cannot create stream when model already has an ID")
}
host.Touch(true)
@@ -66,7 +67,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 stream when model doesn't have an ID")
return eris.New("Cannot update stream when model doesn't have an ID")
}
host.Touch(false)
+3 -1
View File
@@ -6,6 +6,8 @@ import (
"npm/internal/database"
"npm/internal/types"
"github.com/rotisserie/eris"
)
const (
@@ -52,7 +54,7 @@ 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.ID == 0 {