diff --git a/MagicCarpetProject/MagicCarpetContracts/Exceptions/ElementExistsException.cs b/MagicCarpetProject/MagicCarpetContracts/Exceptions/ElementExistsException.cs new file mode 100644 index 0000000..8d4f5a2 --- /dev/null +++ b/MagicCarpetProject/MagicCarpetContracts/Exceptions/ElementExistsException.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MagicCarpetContracts.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/MagicCarpetProject/MagicCarpetContracts/Exceptions/ElementNotFoundException .cs b/MagicCarpetProject/MagicCarpetContracts/Exceptions/ElementNotFoundException .cs new file mode 100644 index 0000000..ed82472 --- /dev/null +++ b/MagicCarpetProject/MagicCarpetContracts/Exceptions/ElementNotFoundException .cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MagicCarpetContracts.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/MagicCarpetProject/MagicCarpetContracts/Exceptions/IncorrectDatesException .cs b/MagicCarpetProject/MagicCarpetContracts/Exceptions/IncorrectDatesException .cs new file mode 100644 index 0000000..c9b3600 --- /dev/null +++ b/MagicCarpetProject/MagicCarpetContracts/Exceptions/IncorrectDatesException .cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MagicCarpetContracts.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/MagicCarpetProject/MagicCarpetContracts/Exceptions/NullListException.cs b/MagicCarpetProject/MagicCarpetContracts/Exceptions/NullListException.cs new file mode 100644 index 0000000..64ca6ae --- /dev/null +++ b/MagicCarpetProject/MagicCarpetContracts/Exceptions/NullListException.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MagicCarpetContracts.Exceptions; + +public class NullListException : Exception +{ + public NullListException() : base("The returned list is null") { } +} diff --git a/MagicCarpetProject/MagicCarpetContracts/Exceptions/StorageException .cs b/MagicCarpetProject/MagicCarpetContracts/Exceptions/StorageException .cs new file mode 100644 index 0000000..d879520 --- /dev/null +++ b/MagicCarpetProject/MagicCarpetContracts/Exceptions/StorageException .cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MagicCarpetContracts.Exceptions; + +public class StorageException : Exception +{ + public StorageException(Exception ex) : base($"Error while working in storage: {ex.Message}", ex) { } +}