diff options
author | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2023-09-03 20:40:37 +0530 |
---|---|---|
committer | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2023-09-03 20:40:37 +0530 |
commit | c6405a7633815042b89bf9de09dc6d78ee7df211 (patch) | |
tree | 482f0338f8420227868e44eb8f449b6ba0212a55 /item/hooks.go | |
parent | 076dcc7633fd0537c0255a98a31a59ca6f5d9de4 (diff) |
changed error message for brand not found when creating item
Diffstat (limited to 'item/hooks.go')
-rw-r--r-- | item/hooks.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/item/hooks.go b/item/hooks.go index 5a27114..c7dc498 100644 --- a/item/hooks.go +++ b/item/hooks.go @@ -20,6 +20,7 @@ package item import ( "gorm.io/gorm" "vidhukant.com/openbills/errors" + e "errors" ) func (i *SavedItem) BeforeSave(tx *gorm.DB) error { @@ -28,6 +29,10 @@ func (i *SavedItem) BeforeSave(tx *gorm.DB) error { // also checks if brand actually exists err = checkBrandOwnership(i.BrandID, i.UserID) if err != nil { + if e.Is(err, errors.ErrBrandNotFound) { + // this error has a better error message for this case + return errors.ErrBrandNotFound + } return err } |