From 2b112deedfe9f14ed53e2c38e40b8506c0941855 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Wed, 15 Nov 2023 09:58:31 +0000 Subject: [PATCH] chore: Remove some duplication of status handling We can't make this entirely pass-through, as we have different semantics in terms of handling details that can't be deserialized. We might want to look at *all* this again in the next major version. --- Google.Api.Gax.Grpc/RpcExceptionExtensions.cs | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/Google.Api.Gax.Grpc/RpcExceptionExtensions.cs b/Google.Api.Gax.Grpc/RpcExceptionExtensions.cs index c78db304..1acb4f92 100644 --- a/Google.Api.Gax.Grpc/RpcExceptionExtensions.cs +++ b/Google.Api.Gax.Grpc/RpcExceptionExtensions.cs @@ -6,7 +6,6 @@ */ using Google.Protobuf; -using Google.Protobuf.WellKnownTypes; using Google.Rpc; using Grpc.Core; using System.Linq; @@ -60,19 +59,9 @@ public static Rpc.Status GetRpcStatus(this RpcException ex) => public static T GetStatusDetail(this RpcException ex) where T : class, IMessage, new() { var status = GetRpcStatus(ex); - if (status is null) - { - return null; - } - var expectedName = new T().Descriptor.FullName; - var any = status.Details.FirstOrDefault(a => Any.GetTypeName(a.TypeUrl) == expectedName); - if (any is null) - { - return null; - } try { - return any.Unpack(); + return status.GetDetail(); } catch {