From a4a75188bd17e31b39a02511bbd6d628bab5c909 Mon Sep 17 00:00:00 2001 From: crupest Date: Sun, 25 Apr 2021 21:20:04 +0800 Subject: ... --- .../Services/Exceptions/EntityAlreadyExistError.cs | 63 ---------------------- 1 file changed, 63 deletions(-) delete mode 100644 BackEnd/Timeline/Services/Exceptions/EntityAlreadyExistError.cs (limited to 'BackEnd/Timeline/Services/Exceptions/EntityAlreadyExistError.cs') diff --git a/BackEnd/Timeline/Services/Exceptions/EntityAlreadyExistError.cs b/BackEnd/Timeline/Services/Exceptions/EntityAlreadyExistError.cs deleted file mode 100644 index 7db2e860..00000000 --- a/BackEnd/Timeline/Services/Exceptions/EntityAlreadyExistError.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Globalization; -using System.Text; - -namespace Timeline.Services.Exceptions -{ - /// - /// Thrown when an entity is already exists. - /// - /// - /// For example, want to create a timeline but a timeline with the same name already exists. - /// - [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; } - } -} -- cgit v1.2.3