RpcException.cs 888 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. namespace JsonRPC4.Common
  6. {
  7. // Token: 0x0200000D RID: 13
  8. public class RpcException : Exception
  9. {
  10. public int ErrorCode
  11. {
  12. get;
  13. }
  14. public object RpcData
  15. {
  16. get;
  17. }
  18. public RpcException(int errorCode, string message, Exception innerException = null, object data = null)
  19. : base(message, innerException)
  20. {
  21. ErrorCode = errorCode;
  22. RpcData = data;
  23. }
  24. public RpcException(RpcErrorCode errorCode, string message, Exception innerException = null, object data = null)
  25. : this((int)errorCode, message, innerException, data)
  26. {
  27. }
  28. public RpcError ToRpcError(bool includeServerErrors)
  29. {
  30. string text = Message;
  31. if (includeServerErrors)
  32. {
  33. text = text + Environment.NewLine + "Exception: " + base.InnerException;
  34. }
  35. return new RpcError(ErrorCode, text, RpcData);
  36. }
  37. }
  38. }