ADD exception file and try1 to fix code smell in database
continuous-integration/drone/push Build is failing Details

pull/19/head
Matheo THIERRY 2 years ago
parent 7b262d20c7
commit b44545a134

@ -53,7 +53,7 @@ namespace Biblioteque_de_Class
{ {
if (logo.GetName() == name) { return logo.GetLogoLink(); } if (logo.GetName() == name) { return logo.GetLogoLink(); }
} }
throw new NullReferenceException("No logo link found."); throw new LogoNotFoundException("No logo link found.");
} }
/// <summary> /// <summary>
@ -68,7 +68,7 @@ namespace Biblioteque_de_Class
return user; return user;
} }
} }
throw new NullReferenceException("No user found with this username."); throw new UserAlreadyUsedException("No user found with this username.");
} }
/// <summary> /// <summary>
@ -103,11 +103,11 @@ namespace Biblioteque_de_Class
{ {
if (existingUser.GetUsername() == user.GetUsername()) if (existingUser.GetUsername() == user.GetUsername())
{ {
throw new Exception("Username already used."); throw new UserAlreadyUsedException("Username already used.");
} }
else if (existingUser.GetEmail() == user.GetEmail()) else if (existingUser.GetEmail() == user.GetEmail())
{ {
throw new Exception("Email already used."); throw new UserAlreadyUsedException("Email already used.");
} }
} }
UserList.Add(user); UserList.Add(user);
@ -124,7 +124,7 @@ namespace Biblioteque_de_Class
} }
else 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()) if (existingTheme.GetName() == theme.GetName())
{ {
throw new Exception("Theme already used."); throw new ThemeAlreadyUsedException("Theme already used.");
} }
} }
ThemeList.Add(theme); ThemeList.Add(theme);
@ -154,7 +154,7 @@ namespace Biblioteque_de_Class
} }
else else
{ {
throw new NullReferenceException("Theme not found."); throw new ThemeNotFoundException("Theme not found.");
} }
} }
@ -170,7 +170,7 @@ namespace Biblioteque_de_Class
return theme; return theme;
} }
} }
throw new NullReferenceException("No theme found with this name."); throw new ThemeNotFoundException("No theme found with this name.");
} }
/// <summary> /// <summary>
@ -186,7 +186,7 @@ namespace Biblioteque_de_Class
return; return;
} }
} }
throw new NullReferenceException("Theme not found."); throw new ThemeNotFoundException("Theme not found.");
} }
/// <summary> /// <summary>
@ -205,7 +205,7 @@ namespace Biblioteque_de_Class
return; return;
} }
} }
throw new NullReferenceException("Theme not found."); throw new ThemeNotFoundException("Theme not found.");
} }
} }
} }

@ -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)
{
}
}
}
Loading…
Cancel
Save