add custom exceptions and start using them in every service

This commit is contained in:
Вячеслав 2025-04-18 14:50:01 +05:00
parent 7bff14a66e
commit eb271793ad
4 changed files with 33 additions and 2 deletions

View file

@ -0,0 +1,10 @@
namespace SurveyBackend.Services.Exceptions;
public class ConflictException : ServiceException
{
public override int StatusCode => 409;
public ConflictException(string message) : base(message)
{
}
}

View file

@ -0,0 +1,10 @@
namespace SurveyBackend.Services.Exceptions;
public abstract class ServiceException : Exception
{
public abstract int StatusCode { get; }
protected ServiceException(string message) : base(message)
{
}
}

View file

@ -0,0 +1,10 @@
namespace SurveyBackend.Services.Exceptions;
public class UnauthorizedException : ServiceException
{
public override int StatusCode => 401;
public UnauthorizedException(string message) : base(message)
{
}
}