say NO to try-catch in controllers
- added ExceptionsMiddleware.cs - added more Exception types - removed all exceptions logic in controllers
This commit is contained in:
parent
eb271793ad
commit
55e82425a9
8 changed files with 75 additions and 20 deletions
|
|
@ -1,6 +1,7 @@
|
|||
using SurveyBackend.Core.Models;
|
||||
using SurveyBackend.Core.Repositories;
|
||||
using SurveyBackend.Core.Services;
|
||||
using SurveyBackend.Services.Exceptions;
|
||||
|
||||
namespace SurveyBackend.Services.Services;
|
||||
|
||||
|
|
@ -13,9 +14,9 @@ public class UserService : IUserService
|
|||
_userRepository = userRepository;
|
||||
}
|
||||
|
||||
public async Task<User?> GetUserByEmail(string email)
|
||||
public async Task<User> GetUserByEmail(string email)
|
||||
{
|
||||
return await _userRepository.GetUserByEmail(email);
|
||||
return await _userRepository.GetUserByEmail(email) ?? throw new NotFoundException("Email not found");
|
||||
}
|
||||
|
||||
public async Task CreateUserAsync(User user)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue