From 3a7765e1fdc0c260182bfd1023dd2aa4a7e5c2eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Mon, 30 Apr 2018 09:42:27 +0300 Subject: [PATCH] Move user friendly exception to Volo.Abp.Core. --- .../Volo/Abp/BusinessException.cs | 11 +- .../Volo/Abp/UI/IUserFriendlyException.cs | 9 ++ .../Volo/Abp/UI/UserFriendlyException.cs | 40 +++++++ .../Volo/Abp/Ui/IUserFriendlyException.cs | 12 -- .../Volo/Abp/Ui/UserFriendlyException.cs | 107 ------------------ 5 files changed, 53 insertions(+), 126 deletions(-) create mode 100644 src/Volo.Abp.Core/Volo/Abp/UI/IUserFriendlyException.cs create mode 100644 src/Volo.Abp.Core/Volo/Abp/UI/UserFriendlyException.cs delete mode 100644 src/Volo.Abp.UI/Volo/Abp/Ui/IUserFriendlyException.cs delete mode 100644 src/Volo.Abp.UI/Volo/Abp/Ui/UserFriendlyException.cs diff --git a/src/Volo.Abp.Core/Volo/Abp/BusinessException.cs b/src/Volo.Abp.Core/Volo/Abp/BusinessException.cs index a47659cf2a..fd7c004d4a 100644 --- a/src/Volo.Abp.Core/Volo/Abp/BusinessException.cs +++ b/src/Volo.Abp.Core/Volo/Abp/BusinessException.cs @@ -17,22 +17,19 @@ namespace Volo.Abp public string Details { get; set; } - public LogLevel LogLevel { get; set; } = LogLevel.Warning; - - public BusinessException() - { - - } + public LogLevel LogLevel { get; set; } public BusinessException( string code = null, string message = null, string details = null, - Exception innerException = null) + Exception innerException = null, + LogLevel logLevel = LogLevel.Warning) : base(message, innerException) { Code = code; Details = details; + LogLevel = logLevel; } /// diff --git a/src/Volo.Abp.Core/Volo/Abp/UI/IUserFriendlyException.cs b/src/Volo.Abp.Core/Volo/Abp/UI/IUserFriendlyException.cs new file mode 100644 index 0000000000..9eb664a72f --- /dev/null +++ b/src/Volo.Abp.Core/Volo/Abp/UI/IUserFriendlyException.cs @@ -0,0 +1,9 @@ +namespace Volo.Abp.UI +{ + //TODO: Move to Volo.Abp namespace + + public interface IUserFriendlyException + { + + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Core/Volo/Abp/UI/UserFriendlyException.cs b/src/Volo.Abp.Core/Volo/Abp/UI/UserFriendlyException.cs new file mode 100644 index 0000000000..54fc7fd091 --- /dev/null +++ b/src/Volo.Abp.Core/Volo/Abp/UI/UserFriendlyException.cs @@ -0,0 +1,40 @@ +using System; +using System.Runtime.Serialization; +using Microsoft.Extensions.Logging; + +namespace Volo.Abp.UI +{ + //TODO: Move to Volo.Abp namespace + + /// + /// This exception type is directly shown to the user. + /// + [Serializable] + public class UserFriendlyException : BusinessException, IUserFriendlyException + { + public UserFriendlyException( + string message, + string code = null, + string details = null, + Exception innerException = null, + LogLevel logLevel = LogLevel.Warning) + : base( + code, + message, + details, + innerException, + logLevel) + { + Details = details; + } + + /// + /// Constructor for serializing. + /// + public UserFriendlyException(SerializationInfo serializationInfo, StreamingContext context) + : base(serializationInfo, context) + { + + } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.UI/Volo/Abp/Ui/IUserFriendlyException.cs b/src/Volo.Abp.UI/Volo/Abp/Ui/IUserFriendlyException.cs deleted file mode 100644 index 25f14fb346..0000000000 --- a/src/Volo.Abp.UI/Volo/Abp/Ui/IUserFriendlyException.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace Volo.Abp.UI -{ - //TODO: Remove IUserFriendlyException. Instead use IBusinessException. - - [Obsolete("Use IBusinessException")] - public interface IUserFriendlyException - { - - } -} \ No newline at end of file diff --git a/src/Volo.Abp.UI/Volo/Abp/Ui/UserFriendlyException.cs b/src/Volo.Abp.UI/Volo/Abp/Ui/UserFriendlyException.cs deleted file mode 100644 index 96dcdd3fc0..0000000000 --- a/src/Volo.Abp.UI/Volo/Abp/Ui/UserFriendlyException.cs +++ /dev/null @@ -1,107 +0,0 @@ -using System; -using System.Runtime.Serialization; -using Microsoft.Extensions.Logging; -using Volo.Abp.ExceptionHandling; -using Volo.Abp.Logging; - -namespace Volo.Abp.UI -{ - //TODO: Remove UserFriendlyException. Instead use BusinessException. - - /// - /// This exception type is directly shown to the user. - /// - [Serializable] - [Obsolete("Use BusinessException")] - public class UserFriendlyException : ApplicationException, - IUserFriendlyException, - IHasLogLevel, - IHasErrorCode, - IHasErrorDetails - { - /// - /// Additional information about the exception. - /// - public string Details { get; set; } - - /// - /// An arbitrary error code. - /// - public string Code { get; set; } - - /// - /// Severity of the exception. - /// Default: Warn. - /// - public LogLevel LogLevel { get; set; } = LogLevel.Warning; - - /// - /// Constructor. - /// - public UserFriendlyException() - { - } - - /// - /// Constructor for serializing. - /// - public UserFriendlyException(SerializationInfo serializationInfo, StreamingContext context) - : base(serializationInfo, context) - { - - } - - /// - /// Constructor. - /// - /// Exception message - public UserFriendlyException(string message) - : base(message) - { - } - - /// - /// Constructor. - /// - /// Exception message - /// Exception severity - public UserFriendlyException(string message, LogLevel logLevel) - : base(message) - { - LogLevel = logLevel; - } - - /// - /// Constructor. - /// - /// Exception message - /// Additional information about the exception - public UserFriendlyException(string message, string details) - : this(message) - { - Details = details; - } - - /// - /// Constructor. - /// - /// Exception message - /// Inner exception - public UserFriendlyException(string message, Exception innerException) - : base(message, innerException) - { - } - - /// - /// Constructor. - /// - /// Exception message - /// Additional information about the exception - /// Inner exception - public UserFriendlyException(string message, string details, Exception innerException) - : this(message, innerException) - { - Details = details; - } - } -} \ No newline at end of file