aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Services/Exceptions/EntityAlreadyExistError.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 /Timeline/Services/Exceptions/EntityAlreadyExistError.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 'Timeline/Services/Exceptions/EntityAlreadyExistError.cs')
-rw-r--r--Timeline/Services/Exceptions/EntityAlreadyExistError.cs63
1 files changed, 0 insertions, 63 deletions
diff --git a/Timeline/Services/Exceptions/EntityAlreadyExistError.cs b/Timeline/Services/Exceptions/EntityAlreadyExistError.cs
deleted file mode 100644
index 7db2e860..00000000
--- a/Timeline/Services/Exceptions/EntityAlreadyExistError.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-using System;
-using System.Globalization;
-using System.Text;
-
-namespace Timeline.Services.Exceptions
-{
- /// <summary>
- /// Thrown when an entity is already exists.
- /// </summary>
- /// <remarks>
- /// For example, want to create a timeline but a timeline with the same name already exists.
- /// </remarks>
- [Serializable]
- public class EntityAlreadyExistException : Exception
- {
- private readonly string? _entityName;
-
- public EntityAlreadyExistException() : this(null, null, null, null) { }
-
- public EntityAlreadyExistException(string? entityName) : this(entityName, null) { }
-
- public EntityAlreadyExistException(string? entityName, Exception? inner) : this(entityName, null, null, null, inner) { }
-
- public EntityAlreadyExistException(string? entityName, object? entity = null) : this(entityName, null, entity, null, null) { }
- public EntityAlreadyExistException(Type? entityType, object? entity = null) : this(null, entityType, entity, null, null) { }
- public EntityAlreadyExistException(string? entityName, Type? entityType, object? entity = null, string? message = null, Exception? inner = null) : base(MakeMessage(entityName, entityType, message), inner)
- {
- _entityName = entityName;
- EntityType = entityType;
- Entity = entity;
- }
-
- 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.EntityAlreadyExistErrorDefault);
- else
- result.AppendFormat(CultureInfo.InvariantCulture, Resources.Services.Exceptions.EntityAlreadyExistError, name);
-
- if (message != null)
- {
- result.Append(' ');
- result.Append(message);
- }
-
- return result.ToString();
- }
-
- protected EntityAlreadyExistException(
- System.Runtime.Serialization.SerializationInfo info,
- System.Runtime.Serialization.StreamingContext context) : base(info, context) { }
-
- public string? EntityName => _entityName ?? (EntityType?.Name);
-
- public Type? EntityType { get; }
-
- public object? Entity { get; }
- }
-}