Browse Source

Move user friendly exception to Volo.Abp.Core.

pull/279/head
Halil İbrahim Kalkan 9 years ago
parent
commit
3a7765e1fd
  1. 11
      src/Volo.Abp.Core/Volo/Abp/BusinessException.cs
  2. 9
      src/Volo.Abp.Core/Volo/Abp/UI/IUserFriendlyException.cs
  3. 40
      src/Volo.Abp.Core/Volo/Abp/UI/UserFriendlyException.cs
  4. 12
      src/Volo.Abp.UI/Volo/Abp/Ui/IUserFriendlyException.cs
  5. 107
      src/Volo.Abp.UI/Volo/Abp/Ui/UserFriendlyException.cs

11
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;
}
/// <summary>

9
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
{
}
}

40
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
/// <summary>
/// This exception type is directly shown to the user.
/// </summary>
[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;
}
/// <summary>
/// Constructor for serializing.
/// </summary>
public UserFriendlyException(SerializationInfo serializationInfo, StreamingContext context)
: base(serializationInfo, context)
{
}
}
}

12
src/Volo.Abp.UI/Volo/Abp/Ui/IUserFriendlyException.cs

@ -1,12 +0,0 @@
using System;
namespace Volo.Abp.UI
{
//TODO: Remove IUserFriendlyException. Instead use IBusinessException.
[Obsolete("Use IBusinessException")]
public interface IUserFriendlyException
{
}
}

107
src/Volo.Abp.UI/Volo/Abp/Ui/UserFriendlyException.cs

@ -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.
/// <summary>
/// This exception type is directly shown to the user.
/// </summary>
[Serializable]
[Obsolete("Use BusinessException")]
public class UserFriendlyException : ApplicationException,
IUserFriendlyException,
IHasLogLevel,
IHasErrorCode,
IHasErrorDetails
{
/// <summary>
/// Additional information about the exception.
/// </summary>
public string Details { get; set; }
/// <summary>
/// An arbitrary error code.
/// </summary>
public string Code { get; set; }
/// <summary>
/// Severity of the exception.
/// Default: Warn.
/// </summary>
public LogLevel LogLevel { get; set; } = LogLevel.Warning;
/// <summary>
/// Constructor.
/// </summary>
public UserFriendlyException()
{
}
/// <summary>
/// Constructor for serializing.
/// </summary>
public UserFriendlyException(SerializationInfo serializationInfo, StreamingContext context)
: base(serializationInfo, context)
{
}
/// <summary>
/// Constructor.
/// </summary>
/// <param name="message">Exception message</param>
public UserFriendlyException(string message)
: base(message)
{
}
/// <summary>
/// Constructor.
/// </summary>
/// <param name="message">Exception message</param>
/// <param name="logLevel">Exception severity</param>
public UserFriendlyException(string message, LogLevel logLevel)
: base(message)
{
LogLevel = logLevel;
}
/// <summary>
/// Constructor.
/// </summary>
/// <param name="message">Exception message</param>
/// <param name="details">Additional information about the exception</param>
public UserFriendlyException(string message, string details)
: this(message)
{
Details = details;
}
/// <summary>
/// Constructor.
/// </summary>
/// <param name="message">Exception message</param>
/// <param name="innerException">Inner exception</param>
public UserFriendlyException(string message, Exception innerException)
: base(message, innerException)
{
}
/// <summary>
/// Constructor.
/// </summary>
/// <param name="message">Exception message</param>
/// <param name="details">Additional information about the exception</param>
/// <param name="innerException">Inner exception</param>
public UserFriendlyException(string message, string details, Exception innerException)
: this(message, innerException)
{
Details = details;
}
}
}
Loading…
Cancel
Save