diff --git a/TheCyclopsProject/TheCyclopsContracts/Exceptions/ElementExistsException.cs b/TheCyclopsProject/TheCyclopsContracts/Exceptions/ElementExistsException.cs new file mode 100644 index 0000000..00494d9 --- /dev/null +++ b/TheCyclopsProject/TheCyclopsContracts/Exceptions/ElementExistsException.cs @@ -0,0 +1,14 @@ +namespace TheCyclopsContracts.Exceptions; + +public class ElementExistsException : Exception +{ + public string ParamName { get; private set; } + + public string ParamValue { get; private set; } + + public ElementExistsException(string paramName, string paramValue) : base($"There is already an element with value {paramValue} of parameter {paramName}") + { + ParamName = paramName; + ParamValue = paramValue; + } +} diff --git a/TheCyclopsProject/TheCyclopsContracts/Exceptions/ElementNotFoundException.cs b/TheCyclopsProject/TheCyclopsContracts/Exceptions/ElementNotFoundException.cs new file mode 100644 index 0000000..d7e45bb --- /dev/null +++ b/TheCyclopsProject/TheCyclopsContracts/Exceptions/ElementNotFoundException.cs @@ -0,0 +1,11 @@ +namespace TheCyclopsContracts.Exceptions; + +public class ElementNotFoundException : Exception +{ + public string Value { get; private set; } + + public ElementNotFoundException(string value) : base($"Element not found at value = {value}") + { + Value = value; + } +} diff --git a/TheCyclopsProject/TheCyclopsContracts/Exceptions/IncorrectDatesException.cs b/TheCyclopsProject/TheCyclopsContracts/Exceptions/IncorrectDatesException.cs new file mode 100644 index 0000000..7df6003 --- /dev/null +++ b/TheCyclopsProject/TheCyclopsContracts/Exceptions/IncorrectDatesException.cs @@ -0,0 +1,8 @@ +namespace TheCyclopsContracts.Exceptions; + +public class IncorrectDatesException : Exception +{ + public IncorrectDatesException(DateTime start, DateTime end) : + base($"The end date must be later than the start date. StartDate: {start:dd.MM.YYYY}. EndDate: {end:dd.MM.YYYY}") + { } +} diff --git a/TheCyclopsProject/TheCyclopsContracts/Exceptions/NullListException.cs b/TheCyclopsProject/TheCyclopsContracts/Exceptions/NullListException.cs new file mode 100644 index 0000000..2a9b8b6 --- /dev/null +++ b/TheCyclopsProject/TheCyclopsContracts/Exceptions/NullListException.cs @@ -0,0 +1,6 @@ +namespace TheCyclopsContracts.Exceptions; + +public class NullListException : Exception +{ + public NullListException() : base("The returned list is null") { } +} diff --git a/TheCyclopsProject/TheCyclopsContracts/Exceptions/StorageException.cs b/TheCyclopsProject/TheCyclopsContracts/Exceptions/StorageException.cs new file mode 100644 index 0000000..64cf31e --- /dev/null +++ b/TheCyclopsProject/TheCyclopsContracts/Exceptions/StorageException.cs @@ -0,0 +1,6 @@ +namespace TheCyclopsContracts.Exceptions; + +public class StorageException : Exception +{ + public StorageException(Exception ex) : base($"Error while working in storage: {ex.Message}", ex) { } +}