Inheritance: Thrift.TException
Example #1
0
 public bool Process(TProtocol iprot, TProtocol oprot)
 {
     try
     {
         TMessage msg = iprot.ReadMessageBegin();
         ProcessFunction fn;
         processMap_.TryGetValue(msg.Name, out fn);
         if (fn == null)
         {
             TProtocolUtil.Skip(iprot, TType.Struct);
             iprot.ReadMessageEnd();
             TApplicationException x = new TApplicationException(TApplicationException.ExceptionType.UnknownMethod, "Invalid method name: '" + msg.Name + "'");
             oprot.WriteMessageBegin(new TMessage(msg.Name, TMessageType.Exception, msg.SeqID));
             x.Write(oprot);
             oprot.WriteMessageEnd();
             oprot.Transport.Flush();
             return true;
         }
         fn(msg.SeqID, iprot, oprot);
     }
     catch (IOException)
     {
         return false;
     }
     return true;
 }
Example #2
0
        private async Task FailAsync(TProtocol oprot, TMessage message, TApplicationException.ExceptionType extype,
            string etxt, CancellationToken cancellationToken)
        {
            var appex = new TApplicationException(extype, etxt);

            var newMessage = new TMessage(message.Name, TMessageType.Exception, message.SeqID);

            await oprot.WriteMessageBeginAsync(newMessage, cancellationToken);
            await appex.WriteAsync(oprot, cancellationToken);
            await oprot.WriteMessageEndAsync(cancellationToken);
            await oprot.Transport.FlushAsync(cancellationToken);
        }