@@ -341,21 +341,26 @@ async def _nexus_error_to_nexus_failure_proto(
341
341
try :
342
342
failure = temporalio .api .failure .v1 .Failure ()
343
343
await self ._data_converter .encode_failure (cause , failure )
344
- # TODO(nexus-preview) Note that Java removes the message from the first
345
- # item in the details chain, since in Java's case the nexus exception
346
- # does not have its own message. In the case of Python however, the
347
- # top-level message belongs to the nexus exception itself and so is
348
- # distinct, and it would be reasonable to expect it to be propagated to
349
- # the caller.
344
+ # nexusrpc.HandlerError and nexusrpc.OperationError have their
345
+ # own error messages and stack traces, independent of any cause
346
+ # exception they may have, and it would be reasonable to expect
347
+ # these to be propagated to the caller.
348
+ #
349
+ # In the case of OperationError (UnsuccessfulOperationError
350
+ # proto), the server takes the message from the top-level
351
+ # UnsuccessfulOperationError and replace the message of the
352
+ # first entry in the details chain with it. Presumably the
353
+ # server is anticipating that we've hoisted the message to that
354
+ # position and is undoing the hoist. Therefore in that case, we
355
+ # put the message from the first entry of the details chain at
356
+ # the top level and accept that the message of the
357
+ # OperationError itself will be lost.
358
+ #
359
+ # Note that other SDKs (e.g. Java) remove the message from the
360
+ # first item in the details chain, since constructors are
361
+ # controlled such that the nexus exception itself does not have
362
+ # its own message.
350
363
#
351
- # In the case of OperationError (UnsuccessfulOperationError proto), the
352
- # server appears to take the message from the top-level
353
- # UnsuccessfulOperationError and replace the message of the first entry
354
- # in the details chain with it. Presumably the server is anticipating
355
- # that we've hoisted the message to that position and is undoing the
356
- # hoist. Therefore in that case, we put the message from the first entry
357
- # of the details chain at the top level and accept that the message of
358
- # the OperationError itself will be lost.
359
364
failure_dict = google .protobuf .json_format .MessageToDict (failure )
360
365
if isinstance (error , nexusrpc .OperationError ):
361
366
message = failure_dict .pop ("message" , str (error ))
0 commit comments