diff options
author | crupest <crupest@outlook.com> | 2021-04-25 21:20:04 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-04-25 21:20:04 +0800 |
commit | 657fb589137099794e58fbd35beb7d942b376965 (patch) | |
tree | 7ab03d970f4c556b0a005f94da2e0752e9d7ce99 /BackEnd/Timeline/Services/Exceptions/ImageException.cs | |
parent | b64806226723df9a9deb64e80defc93860896f50 (diff) | |
download | timeline-657fb589137099794e58fbd35beb7d942b376965.tar.gz timeline-657fb589137099794e58fbd35beb7d942b376965.tar.bz2 timeline-657fb589137099794e58fbd35beb7d942b376965.zip |
...
Diffstat (limited to 'BackEnd/Timeline/Services/Exceptions/ImageException.cs')
-rw-r--r-- | BackEnd/Timeline/Services/Exceptions/ImageException.cs | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/BackEnd/Timeline/Services/Exceptions/ImageException.cs b/BackEnd/Timeline/Services/Exceptions/ImageException.cs deleted file mode 100644 index 20dd48ae..00000000 --- a/BackEnd/Timeline/Services/Exceptions/ImageException.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System;
-using System.Globalization;
-
-namespace Timeline.Services.Exceptions
-{
- [Serializable]
- public class ImageException : Exception
- {
- public enum ErrorReason
- {
- /// <summary>
- /// Decoding image failed.
- /// </summary>
- CantDecode,
- /// <summary>
- /// Decoding succeeded but the real type is not the specified type.
- /// </summary>
- UnmatchedFormat,
- /// <summary>
- /// Image is not of required size.
- /// </summary>
- NotSquare,
- /// <summary>
- /// Other unknown errer.
- /// </summary>
- Unknown
- }
-
- public ImageException() : this(null) { }
- public ImageException(string? message) : this(message, null) { }
- public ImageException(string? message, Exception? inner) : this(ErrorReason.Unknown, null, null, null, message, inner) { }
-
- public ImageException(ErrorReason error, byte[]? data, string? requestType = null, string? realType = null, string? message = null, Exception? inner = null) : base(MakeMessage(error).AppendAdditionalMessage(message), inner) { Error = error; ImageData = data; RequestType = requestType; RealType = realType; }
-
- protected ImageException(
- System.Runtime.Serialization.SerializationInfo info,
- System.Runtime.Serialization.StreamingContext context) : base(info, context) { }
-
- private static string MakeMessage(ErrorReason? reason) =>
- string.Format(CultureInfo.InvariantCulture, Resources.Services.Exceptions.ImageException, reason switch
- {
- ErrorReason.CantDecode => Resources.Services.Exceptions.ImageExceptionCantDecode,
- ErrorReason.UnmatchedFormat => Resources.Services.Exceptions.ImageExceptionUnmatchedFormat,
- ErrorReason.NotSquare => Resources.Services.Exceptions.ImageExceptionBadSize,
- _ => Resources.Services.Exceptions.ImageExceptionUnknownError
- });
-
- public ErrorReason Error { get; }
-#pragma warning disable CA1819 // Properties should not return arrays
- public byte[]? ImageData { get; }
-#pragma warning restore CA1819 // Properties should not return arrays
- public string? RequestType { get; }
-
- // This field will be null if decoding failed.
- public string? RealType { get; }
- }
-}
|