示例#1
0
 public JsonRpcErrorException(JsonRpcErrorCode errorCode, string message) : base(message)
 {
     Error = new JsonRpcError
     {
         Code    = (long)errorCode,
         Message = message
     };
 }
示例#2
0
 public JsonRpcErrorException(JsonRpcError err) : base(err.Message)
 {
     Error = err;
     if (err.Data is JObject dataDict)
     {
         ServerData = dataDict.ToString(Formatting.Indented);
         // Populate this exception Data dictionary with entries from the RPC data object.
         foreach (var entry in dataDict)
         {
             var entryVal = entry.Value.ToString();
             Data[entry.Key] = entryVal;
         }
     }
     else
     {
         ServerData = err.Data?.ToString() ?? string.Empty;
     }
 }
示例#3
0
        public JsonRpcErrorException(JsonRpcErrorCode errorCode, string message, Exception ex) : base(message, ex)
        {
            Error = new JsonRpcError
            {
                Code    = (long)errorCode,
                Message = message
            };
            var dataDict = new Dictionary <string, object>();

            dataDict["exception"] = ex.ToString();
            // Populate the RPC data object with entries from the exception's Data dictionary.
            foreach (var item in ex.Data.Keys)
            {
                var dataVal = ex.Data[item];
                if (dataVal != null)
                {
                    dataDict[item.ToString()] = dataVal.ToString();
                }
            }

            Error.Data = dataDict;
        }