refac: missing user or article is reported with a domain not-found error instead of a raw GORM error, and the API answers 404 for it
This commit is contained in:
1 parent
7c57173497
commit
8460a078e3
13 files changed
+426
-32
No files matched your search
@@ -0,0 +1,14 @@
|
||||
package persistence
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func mapNotFoundErr(err error, sentinel error) error {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return sentinel
|
||||
}
|
||||
return err
|
||||
}
|
||||
Reference in new issue
Block a user