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
+3
-3
@@ -34,7 +34,7 @@ func (m *mockUserRepo) Get(id uint32) (user.User, error) {
|
||||
}
|
||||
u, ok := m.users[id]
|
||||
if !ok {
|
||||
return user.User{}, gorm.ErrRecordNotFound
|
||||
return user.User{}, user.ErrUserNotFound
|
||||
}
|
||||
return u, nil
|
||||
}
|
||||
@@ -49,7 +49,7 @@ func (m *mockUserRepo) GetByUsername(username string) (user.User, error) {
|
||||
return u, nil
|
||||
}
|
||||
}
|
||||
return user.User{}, gorm.ErrRecordNotFound
|
||||
return user.User{}, user.ErrUserNotFound
|
||||
}
|
||||
|
||||
func (m *mockUserRepo) GetByEmail(email string) (user.User, error) {
|
||||
@@ -62,7 +62,7 @@ func (m *mockUserRepo) GetByEmail(email string) (user.User, error) {
|
||||
return u, nil
|
||||
}
|
||||
}
|
||||
return user.User{}, gorm.ErrRecordNotFound
|
||||
return user.User{}, user.ErrUserNotFound
|
||||
}
|
||||
|
||||
func (m *mockUserRepo) GetAll() []user.User {
|
||||
|
||||
Reference in new issue
Block a user