diff --git a/notus/Biblioteque_de_Class/Database.cs b/notus/Biblioteque_de_Class/Database.cs index e6f641c..d094647 100644 --- a/notus/Biblioteque_de_Class/Database.cs +++ b/notus/Biblioteque_de_Class/Database.cs @@ -53,7 +53,7 @@ namespace Biblioteque_de_Class { if (logo.GetName() == name) { return logo.GetLogoLink(); } } - throw new NullReferenceException("No logo link found."); + throw new LogoNotFoundException("No logo link found."); } /// @@ -68,7 +68,7 @@ namespace Biblioteque_de_Class return user; } } - throw new NullReferenceException("No user found with this username."); + throw new UserAlreadyUsedException("No user found with this username."); } /// @@ -103,11 +103,11 @@ namespace Biblioteque_de_Class { if (existingUser.GetUsername() == user.GetUsername()) { - throw new Exception("Username already used."); + throw new UserAlreadyUsedException("Username already used."); } else if (existingUser.GetEmail() == user.GetEmail()) { - throw new Exception("Email already used."); + throw new UserAlreadyUsedException("Email already used."); } } UserList.Add(user); @@ -124,7 +124,7 @@ namespace Biblioteque_de_Class } else { - throw new NullReferenceException("User not found."); + throw new UserNotFoundException("User not found."); } } @@ -137,7 +137,7 @@ namespace Biblioteque_de_Class { if (existingTheme.GetName() == theme.GetName()) { - throw new Exception("Theme already used."); + throw new ThemeAlreadyUsedException("Theme already used."); } } ThemeList.Add(theme); @@ -154,7 +154,7 @@ namespace Biblioteque_de_Class } else { - throw new NullReferenceException("Theme not found."); + throw new ThemeNotFoundException("Theme not found."); } } @@ -170,7 +170,7 @@ namespace Biblioteque_de_Class return theme; } } - throw new NullReferenceException("No theme found with this name."); + throw new ThemeNotFoundException("No theme found with this name."); } /// @@ -186,7 +186,7 @@ namespace Biblioteque_de_Class return; } } - throw new NullReferenceException("Theme not found."); + throw new ThemeNotFoundException("Theme not found."); } /// @@ -205,7 +205,7 @@ namespace Biblioteque_de_Class return; } } - throw new NullReferenceException("Theme not found."); + throw new ThemeNotFoundException("Theme not found."); } } } \ No newline at end of file diff --git a/notus/Biblioteque_de_Class/Exception.cs b/notus/Biblioteque_de_Class/Exception.cs new file mode 100644 index 0000000..cc1b46c --- /dev/null +++ b/notus/Biblioteque_de_Class/Exception.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Biblioteque_de_Class +{ + public class LogoNotFoundException : Exception + { + public LogoNotFoundException(string message) : base(message) + { + } + } + public class UserNotFoundException : Exception + { + public UserNotFoundException(string message) : base(message) + { + } + } + public class ThemeNotFoundException : Exception + { + public ThemeNotFoundException(string message) : base(message) + { + } + } + public class ThemeAlreadyUsedException : Exception + { + public ThemeAlreadyUsedException(string message) : base(message) + { + } + } +}