aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Services/Exceptions/TimelinePostNotExistException.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-06-13 00:28:35 +0800
committercrupest <crupest@outlook.com>2020-06-13 00:28:35 +0800
commiteba8e9698c09b805d8ac2a8f58db93b947ac29e3 (patch)
treec3bf0aef9d80c19e9a71e9e9aaab16b8364db15b /Timeline/Services/Exceptions/TimelinePostNotExistException.cs
parentcc62df19e5f8aa216660915f46ff290c8eeab1d0 (diff)
downloadtimeline-eba8e9698c09b805d8ac2a8f58db93b947ac29e3.tar.gz
timeline-eba8e9698c09b805d8ac2a8f58db93b947ac29e3.tar.bz2
timeline-eba8e9698c09b805d8ac2a8f58db93b947ac29e3.zip
refactor(back): Fix #100 .
Diffstat (limited to 'Timeline/Services/Exceptions/TimelinePostNotExistException.cs')
-rw-r--r--Timeline/Services/Exceptions/TimelinePostNotExistException.cs33
1 files changed, 33 insertions, 0 deletions
diff --git a/Timeline/Services/Exceptions/TimelinePostNotExistException.cs b/Timeline/Services/Exceptions/TimelinePostNotExistException.cs
new file mode 100644
index 00000000..bbb9e908
--- /dev/null
+++ b/Timeline/Services/Exceptions/TimelinePostNotExistException.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Globalization;
+
+namespace Timeline.Services.Exceptions
+{
+ [Serializable]
+ public class TimelinePostNotExistException : EntityNotExistException
+ {
+ public TimelinePostNotExistException() { }
+ [Obsolete("This has no meaning.")]
+ public TimelinePostNotExistException(string? message) : this(message, null) { }
+ [Obsolete("This has no meaning.")]
+ public TimelinePostNotExistException(string? message, Exception? inner) : this(null, null, false, message, inner) { }
+ protected TimelinePostNotExistException(
+ System.Runtime.Serialization.SerializationInfo info,
+ System.Runtime.Serialization.StreamingContext context) : base(info, context) { }
+
+ public TimelinePostNotExistException(string? timelineName, long? id, bool isDelete, string? message = null, Exception? inner = null) : base(EntityNames.TimelinePost, null, MakeMessage(timelineName, id, isDelete).AppendAdditionalMessage(message), inner) { TimelineName = timelineName; Id = id; IsDelete = isDelete; }
+
+ private static string MakeMessage(string? timelineName, long? id, bool isDelete)
+ {
+ return string.Format(CultureInfo.InvariantCulture, isDelete ? Resources.Services.Exceptions.TimelinePostNotExistExceptionDeleted : Resources.Services.Exceptions.TimelinePostNotExistException, timelineName ?? "", id);
+ }
+
+ public string? TimelineName { get; set; }
+ public long? Id { get; set; }
+
+ /// <summary>
+ /// True if the post is deleted. False if the post does not exist at all.
+ /// </summary>
+ public bool IsDelete { get; set; }
+ }
+}