From 1ca954dfb8bba21a10e0a43bd075ecd7d470621c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AD=D0=B3=D0=BE=D0=B2=20=D0=95=D0=B2=D0=B3=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B9?= Date: Wed, 5 Feb 2025 20:43:06 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BA=D0=BB=D1=8E=D1=87=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Exceptions/ElementExistsException.cs | 14 ++++++++++++++ .../Exceptions/ElementNotFoundException.cs | 11 +++++++++++ .../Exceptions/IncorrectDatesException.cs | 6 ++++++ .../Exceptions/NullListException.cs | 6 ++++++ .../Exceptions/StorageException.cs | 6 ++++++ 5 files changed, 43 insertions(+) create mode 100644 TheCatHasPawsProject/CatHasPawsContratcs/Exceptions/ElementExistsException.cs create mode 100644 TheCatHasPawsProject/CatHasPawsContratcs/Exceptions/ElementNotFoundException.cs create mode 100644 TheCatHasPawsProject/CatHasPawsContratcs/Exceptions/IncorrectDatesException.cs create mode 100644 TheCatHasPawsProject/CatHasPawsContratcs/Exceptions/NullListException.cs create mode 100644 TheCatHasPawsProject/CatHasPawsContratcs/Exceptions/StorageException.cs diff --git a/TheCatHasPawsProject/CatHasPawsContratcs/Exceptions/ElementExistsException.cs b/TheCatHasPawsProject/CatHasPawsContratcs/Exceptions/ElementExistsException.cs new file mode 100644 index 0000000..2ad3aaf --- /dev/null +++ b/TheCatHasPawsProject/CatHasPawsContratcs/Exceptions/ElementExistsException.cs @@ -0,0 +1,14 @@ +namespace CatHasPawsContratcs.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/TheCatHasPawsProject/CatHasPawsContratcs/Exceptions/ElementNotFoundException.cs b/TheCatHasPawsProject/CatHasPawsContratcs/Exceptions/ElementNotFoundException.cs new file mode 100644 index 0000000..a6775f5 --- /dev/null +++ b/TheCatHasPawsProject/CatHasPawsContratcs/Exceptions/ElementNotFoundException.cs @@ -0,0 +1,11 @@ +namespace CatHasPawsContratcs.Exceptions; + +public class ElementNotFoundException : Exception +{ + public string Value { get; private set; } + + public ElementNotFoundException(string value) : base($"Element not found at value = {value}") + { + Value = value; + } +} \ No newline at end of file diff --git a/TheCatHasPawsProject/CatHasPawsContratcs/Exceptions/IncorrectDatesException.cs b/TheCatHasPawsProject/CatHasPawsContratcs/Exceptions/IncorrectDatesException.cs new file mode 100644 index 0000000..4b9e71b --- /dev/null +++ b/TheCatHasPawsProject/CatHasPawsContratcs/Exceptions/IncorrectDatesException.cs @@ -0,0 +1,6 @@ +namespace CatHasPawsContratcs.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/TheCatHasPawsProject/CatHasPawsContratcs/Exceptions/NullListException.cs b/TheCatHasPawsProject/CatHasPawsContratcs/Exceptions/NullListException.cs new file mode 100644 index 0000000..9de85e0 --- /dev/null +++ b/TheCatHasPawsProject/CatHasPawsContratcs/Exceptions/NullListException.cs @@ -0,0 +1,6 @@ +namespace CatHasPawsContratcs.Exceptions; + +public class NullListException : Exception +{ + public NullListException() : base("The returned list is null") { } +} diff --git a/TheCatHasPawsProject/CatHasPawsContratcs/Exceptions/StorageException.cs b/TheCatHasPawsProject/CatHasPawsContratcs/Exceptions/StorageException.cs new file mode 100644 index 0000000..714e4f2 --- /dev/null +++ b/TheCatHasPawsProject/CatHasPawsContratcs/Exceptions/StorageException.cs @@ -0,0 +1,6 @@ +namespace CatHasPawsContratcs.Exceptions; + +public class StorageException : Exception +{ + public StorageException(Exception ex) : base($"Error while working in storage: {ex.Message}", ex) { } +} \ No newline at end of file