Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Exposed RpcException property to SpannerException #9527

Merged
merged 2 commits into from
Jan 11, 2023

Conversation

anuragsrivstv
Copy link
Contributor

In this PR we have exposed InnerException of SpannerException via RpcException property.

@anuragsrivstv anuragsrivstv added do not merge Indicates a pull request not ready for merge, due to either quality or timing. lex-review PR opened for LEX team review labels Jan 10, 2023
@@ -93,6 +93,11 @@ public bool IsRetryable
/// </summary>
public TimeSpan? RecommendedRetryDelay { get; }

/// <summary>
/// Gets the underlying <see cref="Grpc.Core.RpcException"/>.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would reword "Gets" to "Returns", but more importantly point out that this may be null, if the SpannerException was not caused by an RpcException.

namespace Google.Cloud.Spanner.Data.Tests;
public class SpannerExceptionTests
{
private static readonly Status s_status = new Status(StatusCode.InvalidArgument, "Bad request");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just move into the single test that uses it, as a local variable?

public void SpannerExceptionContainsRpcExceptionAsInnerException()
{
var rpcExceptionMessage = "Test RpcException Message";
var rpcexception = new RpcException(s_status, rpcExceptionMessage);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: rename to rpcException.


var spannerExceptionWithoutInnerExcpetion = new SpannerException(ErrorCode.InvalidArgument, "Invalid Argument Message");

Assert.NotNull(spannerExceptionWithInnerExcpetion_1.RpcException);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these can just be Assert.Same(rpcException, spannerExceptionWithInnerExcpetion_1.RpcException);

var rpcExceptionMessage = "Test RpcException Message";
var rpcexception = new RpcException(s_status, rpcExceptionMessage);

var spannerExceptionWithInnerExcpetion_1 = new SpannerException(rpcexception);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Excpetion => Exception, and I'd lose the underscores.

@anuragsrivstv anuragsrivstv marked this pull request as ready for review January 10, 2023 13:01
@anuragsrivstv anuragsrivstv requested a review from a team as a code owner January 10, 2023 13:01
@anuragsrivstv anuragsrivstv removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Jan 10, 2023
@anuragsrivstv anuragsrivstv merged commit 4c96a04 into googleapis:main Jan 11, 2023
jskeet added a commit that referenced this pull request Feb 8, 2023
Changes in Google.Cloud.Spanner.Data version 4.3.0:

- Enable REST transport in C# ([commit f6a1c3e](f6a1c3e))
- Exposed RpcException property to SpannerException ([issue 9527](#9527)) ([commit 4c96a04](4c96a04))

Packages in this release:
- Release Google.Cloud.Spanner.Admin.Database.V1 version 4.3.0
- Release Google.Cloud.Spanner.Admin.Instance.V1 version 4.3.0
- Release Google.Cloud.Spanner.Common.V1 version 4.3.0
- Release Google.Cloud.Spanner.Data version 4.3.0
- Release Google.Cloud.Spanner.V1 version 4.3.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lex-review PR opened for LEX team review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants