aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline/Services/Exceptions/EntityNotExistError.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-10-31 00:42:06 +0800
committerGitHub <noreply@github.com>2020-10-31 00:42:06 +0800
commita3c97f6fb6313da2e8c0fac0b4c08f2ef4265d0f (patch)
treeee006874b0c93e9bfc76f141a092a8b9585a1f95 /BackEnd/Timeline/Services/Exceptions/EntityNotExistError.cs
parent0c4caaebe2480e77918d5d7df234f0edaeab74ba (diff)
parent7ce0846d9ec968da3ea4f7ebcc6db26db8e49089 (diff)
downloadtimeline-a3c97f6fb6313da2e8c0fac0b4c08f2ef4265d0f.tar.gz
timeline-a3c97f6fb6313da2e8c0fac0b4c08f2ef4265d0f.tar.bz2
timeline-a3c97f6fb6313da2e8c0fac0b4c08f2ef4265d0f.zip
Merge pull request #161 from crupest/upgrade
Upgrade packages and split front end and back end.
Diffstat (limited to 'BackEnd/Timeline/Services/Exceptions/EntityNotExistError.cs')
-rw-r--r--BackEnd/Timeline/Services/Exceptions/EntityNotExistError.cs55
1 files changed, 55 insertions, 0 deletions
diff --git a/BackEnd/Timeline/Services/Exceptions/EntityNotExistError.cs b/BackEnd/Timeline/Services/Exceptions/EntityNotExistError.cs
new file mode 100644
index 00000000..e79496d3
--- /dev/null
+++ b/BackEnd/Timeline/Services/Exceptions/EntityNotExistError.cs
@@ -0,0 +1,55 @@
+using System;
+using System.Globalization;
+using System.Text;
+
+namespace Timeline.Services.Exceptions
+{
+ /// <summary>
+ /// Thrown when you want to get an entity that does not exist.
+ /// </summary>
+ /// <example>
+ /// For example, you want to get a timeline with given name but it does not exist.
+ /// </example>
+ [Serializable]
+ public class EntityNotExistException : Exception
+ {
+ public EntityNotExistException() : this(null, null, null, null) { }
+ public EntityNotExistException(string? entityName) : this(entityName, null, null, null) { }
+ public EntityNotExistException(Type? entityType) : this(null, entityType, null, null) { }
+ public EntityNotExistException(string? entityName, Exception? inner) : this(entityName, null, null, inner) { }
+ public EntityNotExistException(Type? entityType, Exception? inner) : this(null, entityType, null, inner) { }
+ public EntityNotExistException(string? entityName, Type? entityType, string? message = null, Exception? inner = null) : base(MakeMessage(entityName, entityType, message), inner)
+ {
+ EntityName = entityName;
+ EntityType = entityType;
+ }
+
+ private static string MakeMessage(string? entityName, Type? entityType, string? message)
+ {
+ string? name = entityName ?? (entityType?.Name);
+
+ var result = new StringBuilder();
+
+ if (name == null)
+ result.Append(Resources.Services.Exceptions.EntityNotExistErrorDefault);
+ else
+ result.AppendFormat(CultureInfo.InvariantCulture, Resources.Services.Exceptions.EntityNotExistError, name);
+
+ if (message != null)
+ {
+ result.Append(' ');
+ result.Append(message);
+ }
+
+ return result.ToString();
+ }
+
+ protected EntityNotExistException(
+ System.Runtime.Serialization.SerializationInfo info,
+ System.Runtime.Serialization.StreamingContext context) : base(info, context) { }
+
+ public string? EntityName { get; }
+
+ public Type? EntityType { get; }
+ }
+}