Browse Source

添加 UnauthorizedException

master
王厅 3 days ago
parent
commit
7821fdb701
  1. 46
      Apewer/UnauthorizedException.cs

46
Apewer/UnauthorizedException.cs

@ -0,0 +1,46 @@
using System;
namespace Apewer
{
/// <summary>表示未授权的错误。</summary>
/// <remarks>默认消息:Operation is not authorized.</remarks>
public class UnauthorizedException : Exception
{
static string _default = FixMessage(null);
static string FixMessage(string message)
{
const string Preset = "Operation is not authorized.";
if (message != null)
{
message = message.Trim();
if (!string.IsNullOrEmpty(message)) return message;
}
return Preset;
}
/// <summary>获取或设置默认消息。</summary>
public static string DefaultMessage { get => _default; set => _default = FixMessage(value); }
/// <summary>状态。</summary>
/// <value>Unauthorized</value>
public virtual string Status { get => "Unauthorized"; }
/// <summary>表示未授权的错误,此时应在前端发起授权。</summary>
/// <remarks>默认消息:Operation is not authorized.</remarks>
public UnauthorizedException() : base(DefaultMessage) { }
/// <summary>表示未授权的错误,此时应在前端发起授权。</summary>
/// <remarks>默认消息:Operation is not authorized.</remarks>
public UnauthorizedException(string message) : base(FixMessage(message)) { }
/// <summary>表示未授权的错误,此时应在前端发起授权。</summary>
/// <remarks>默认消息:Operation is not authorized.</remarks>
public UnauthorizedException(string message, Exception innerException) : base(FixMessage(message), innerException) { }
}
}
Loading…
Cancel
Save