Exceptions aren't propagated from server to client
If the server raises an exception then those exceptions aren't propagated to the client. The normal thrift library automatically handles this by sending a ThriftApplicationException from the server to the client as part of the response message.
How can I propagate exceptions from the server to the client using aiothrift? Any help would be appreciated.
Instead of an application exception on the client-side, I get an IncompleteReadError exception followed by a ConnectionClosedError
Traceback (most recent call last): File "/home/vaastav/anaconda3/lib/python3.8/site-packages/aiothrift/connection.py", line 119, in execute result = await self._recv(api) File "/home/vaastav/anaconda3/lib/python3.8/site-packages/aiothrift/connection.py", line 136, in _recv fname, mtype, rseqid = await self._iprot.read_message_begin() File "/home/vaastav/anaconda3/lib/python3.8/site-packages/aiothrift/protocol.py", line 469, in read_message_begin api, ttype, seqid = await read_message_begin( File "/home/vaastav/anaconda3/lib/python3.8/site-packages/aiothrift/protocol.py", line 159, in read_message_begin data = await reader.readexactly(4) File "/home/vaastav/anaconda3/lib/python3.8/asyncio/streams.py", line 721, in readexactly raise exceptions.IncompleteReadError(incomplete, n) asyncio.exceptions.IncompleteReadError: 0 bytes read on a total of 4 expected bytes
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "client.py", line 16, in
I'm not sure if it's appropriate to raise some kind of ThriftApplicationException. Maybe we could hijack the server exception and manually create a thrift exception and send that back to client, I just wonder if it's the best way to do it.
I think the most simple solution is to define an exception struct in your thrift file and throws that exception in your Service like
service PingPong {
string ping() throws (1:SampleException error),
}
exception SampleException {
1: list<string> failed
}