using System; namespace Apewer { /// 表示未授权的错误。 /// 默认消息:Operation is not authorized. 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; } /// 获取或设置默认消息。 public static string DefaultMessage { get => _default; set => _default = FixMessage(value); } /// 状态。 /// Unauthorized public virtual string Status { get => "Unauthorized"; } /// 表示未授权的错误,此时应在前端发起授权。 /// 默认消息:Operation is not authorized. public UnauthorizedException() : base(DefaultMessage) { } /// 表示未授权的错误,此时应在前端发起授权。 /// 默认消息:Operation is not authorized. public UnauthorizedException(string message) : base(FixMessage(message)) { } /// 表示未授权的错误,此时应在前端发起授权。 /// 默认消息:Operation is not authorized. public UnauthorizedException(string message, Exception innerException) : base(FixMessage(message), innerException) { } } }