You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.7 KiB
46 lines
1.7 KiB
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) { }
|
|
|
|
}
|
|
|
|
}
|
|
|