GameException.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System;
  2. namespace Base
  3. {
  4. [Serializable]
  5. public class GameException: Exception
  6. {
  7. public GameException(string message): base(message)
  8. {
  9. }
  10. public GameException(string message, Exception e): base(message, e)
  11. {
  12. }
  13. }
  14. /// <summary>
  15. /// 输入异常,比如没有输入密码账号
  16. /// </summary>
  17. [Serializable]
  18. public class InputErrorException : Exception
  19. {
  20. public InputErrorException(string message) : base(message)
  21. {
  22. }
  23. public InputErrorException(string message, Exception e) : base(message, e)
  24. {
  25. }
  26. }
  27. /// <summary>
  28. /// 配置异常
  29. /// </summary>
  30. [Serializable]
  31. public class ConfigException : Exception
  32. {
  33. public ConfigException(string message) : base(message)
  34. {
  35. }
  36. public ConfigException(string message, Exception e) : base(message, e)
  37. {
  38. }
  39. }
  40. /// <summary>
  41. /// RPC异常,带ErrorCode
  42. /// </summary>
  43. [Serializable]
  44. public class RpcException : Exception
  45. {
  46. public ErrorCode Error { get; private set; }
  47. public RpcException(ErrorCode error, string message) : base($"{(int)error} : {message}")
  48. {
  49. this.Error = error;
  50. }
  51. public RpcException(ErrorCode error, string message, Exception e) : base($"{(int)error} : {message}", e)
  52. {
  53. this.Error = error;
  54. }
  55. }
  56. }