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.

31 lines
789 B

3 years ago
2 years ago
3 years ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace Apewer.Web
  5. {
  6. /// <summary>表示在 API 执行过程中发生的错误。</summary>
  7. public sealed class ApiException : Exception
  8. {
  9. string _status = null;
  10. /// <summary>表示 API 状态。</summary>
  11. public string Status { get { return _status; } }
  12. internal ApiException(string message, string status = "exception") : base(FixMessage(message))
  13. {
  14. _status = status;
  15. }
  16. static string FixMessage(string message)
  17. {
  18. var msg = TextUtility.Trim(message);
  19. if (string.IsNullOrEmpty(msg)) msg = "在执行 API 的过程中发生了未定义消息的错误。";
  20. return msg;
  21. }
  22. }
  23. }