@@ -381,7 +381,6 @@ async def deserialize(
381
381
raise nexusrpc .HandlerError (
382
382
"Data converter failed to decode Nexus operation input" ,
383
383
type = nexusrpc .HandlerErrorType .BAD_REQUEST ,
384
- cause = err ,
385
384
retryable = False ,
386
385
) from err
387
386
@@ -393,36 +392,32 @@ def _exception_to_handler_error(err: BaseException) -> nexusrpc.HandlerError:
393
392
if isinstance (err , nexusrpc .HandlerError ):
394
393
return err
395
394
elif isinstance (err , ApplicationError ):
396
- return nexusrpc .HandlerError (
395
+ handler_err = nexusrpc .HandlerError (
397
396
# TODO(nexus-prerelease): what should message be?
398
397
err .message ,
399
398
type = nexusrpc .HandlerErrorType .INTERNAL ,
400
- cause = err ,
401
399
retryable = not err .non_retryable ,
402
400
)
403
401
elif isinstance (err , RPCError ):
404
402
if err .status == RPCStatusCode .INVALID_ARGUMENT :
405
- return nexusrpc .HandlerError (
403
+ handler_err = nexusrpc .HandlerError (
406
404
err .message ,
407
405
type = nexusrpc .HandlerErrorType .BAD_REQUEST ,
408
- cause = err ,
409
406
)
410
407
elif err .status in [
411
408
RPCStatusCode .ALREADY_EXISTS ,
412
409
RPCStatusCode .FAILED_PRECONDITION ,
413
410
RPCStatusCode .OUT_OF_RANGE ,
414
411
]:
415
- return nexusrpc .HandlerError (
412
+ handler_err = nexusrpc .HandlerError (
416
413
err .message ,
417
414
type = nexusrpc .HandlerErrorType .INTERNAL ,
418
- cause = err ,
419
415
retryable = False ,
420
416
)
421
417
elif err .status in [RPCStatusCode .ABORTED , RPCStatusCode .UNAVAILABLE ]:
422
- return nexusrpc .HandlerError (
418
+ handler_err = nexusrpc .HandlerError (
423
419
err .message ,
424
420
type = nexusrpc .HandlerErrorType .UNAVAILABLE ,
425
- cause = err ,
426
421
)
427
422
elif err .status in [
428
423
RPCStatusCode .CANCELLED ,
@@ -436,37 +431,36 @@ def _exception_to_handler_error(err: BaseException) -> nexusrpc.HandlerError:
436
431
# we convert to internal because this is not a client auth error and happens
437
432
# when the handler fails to auth with Temporal and should be considered
438
433
# retryable.
439
- return nexusrpc .HandlerError (
440
- err .message , type = nexusrpc .HandlerErrorType .INTERNAL , cause = err
434
+ handler_err = nexusrpc .HandlerError (
435
+ err .message , type = nexusrpc .HandlerErrorType .INTERNAL
441
436
)
442
437
elif err .status == RPCStatusCode .NOT_FOUND :
443
- return nexusrpc .HandlerError (
444
- err .message , type = nexusrpc .HandlerErrorType .NOT_FOUND , cause = err
438
+ handler_err = nexusrpc .HandlerError (
439
+ err .message , type = nexusrpc .HandlerErrorType .NOT_FOUND
445
440
)
446
441
elif err .status == RPCStatusCode .RESOURCE_EXHAUSTED :
447
- return nexusrpc .HandlerError (
442
+ handler_err = nexusrpc .HandlerError (
448
443
err .message ,
449
444
type = nexusrpc .HandlerErrorType .RESOURCE_EXHAUSTED ,
450
- cause = err ,
451
445
)
452
446
elif err .status == RPCStatusCode .UNIMPLEMENTED :
453
- return nexusrpc .HandlerError (
447
+ handler_err = nexusrpc .HandlerError (
454
448
err .message ,
455
449
type = nexusrpc .HandlerErrorType .NOT_IMPLEMENTED ,
456
- cause = err ,
457
450
)
458
451
elif err .status == RPCStatusCode .DEADLINE_EXCEEDED :
459
- return nexusrpc .HandlerError (
452
+ handler_err = nexusrpc .HandlerError (
460
453
err .message ,
461
454
type = nexusrpc .HandlerErrorType .UPSTREAM_TIMEOUT ,
462
- cause = err ,
463
455
)
464
456
else :
465
- return nexusrpc .HandlerError (
457
+ handler_err = nexusrpc .HandlerError (
466
458
f"Unhandled RPC error status: { err .status } " ,
467
459
type = nexusrpc .HandlerErrorType .INTERNAL ,
468
- cause = err ,
469
460
)
470
- return nexusrpc .HandlerError (
471
- str (err ), type = nexusrpc .HandlerErrorType .INTERNAL , cause = err
472
- )
461
+ else :
462
+ handler_err = nexusrpc .HandlerError (
463
+ str (err ), type = nexusrpc .HandlerErrorType .INTERNAL
464
+ )
465
+ handler_err .__cause__ = err
466
+ return handler_err
0 commit comments