Skip to content

Commit

Permalink
chore: Remove some duplication of status handling
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jskeet committed Nov 15, 2023
1 parent 47d0e7f commit 2b112de
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions Google.Api.Gax.Grpc/RpcExceptionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

using Google.Protobuf;
using Google.Protobuf.WellKnownTypes;
using Google.Rpc;
using Grpc.Core;
using System.Linq;
Expand Down Expand Up @@ -60,19 +59,9 @@ public static Rpc.Status GetRpcStatus(this RpcException ex) =>
public static T GetStatusDetail<T>(this RpcException ex) where T : class, IMessage<T>, 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<T>();
return status.GetDetail<T>();
}
catch
{
Expand Down

0 comments on commit 2b112de

Please sign in to comment.