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.

47 lines
1.7 KiB

  1. using Apewer.Web;
  2. using System;
  3. namespace Apewer
  4. {
  5. /// <summary>表示未授权的错误。</summary>
  6. /// <remarks>默认消息:Operation is not authorized.</remarks>
  7. public class UnauthorizedException : Exception, IApiException
  8. {
  9. static string _default = FixMessage(null);
  10. static string FixMessage(string message)
  11. {
  12. const string Preset = "Operation is not authorized.";
  13. if (message != null)
  14. {
  15. message = message.Trim();
  16. if (!string.IsNullOrEmpty(message)) return message;
  17. }
  18. return Preset;
  19. }
  20. /// <summary>获取或设置默认消息。</summary>
  21. public static string DefaultMessage { get => _default; set => _default = FixMessage(value); }
  22. /// <summary>状态。</summary>
  23. /// <value>Unauthorized</value>
  24. public virtual string Status { get => "Unauthorized"; }
  25. /// <summary>表示未授权的错误,此时应在前端发起授权。</summary>
  26. /// <remarks>默认消息:Operation is not authorized.</remarks>
  27. public UnauthorizedException() : base(DefaultMessage) { }
  28. /// <summary>表示未授权的错误,此时应在前端发起授权。</summary>
  29. /// <remarks>默认消息:Operation is not authorized.</remarks>
  30. public UnauthorizedException(string message) : base(FixMessage(message)) { }
  31. /// <summary>表示未授权的错误,此时应在前端发起授权。</summary>
  32. /// <remarks>默认消息:Operation is not authorized.</remarks>
  33. public UnauthorizedException(string message, Exception innerException) : base(FixMessage(message), innerException) { }
  34. }
  35. }