Skip to content
This repository was archived by the owner on Sep 26, 2023. It is now read-only.

Support individual API exception types - #357

Merged
shinfan merged 8 commits into
googleapis:masterfrom
shinfan:master
Aug 25, 2017
Merged

Support individual API exception types#357
shinfan merged 8 commits into
googleapis:masterfrom
shinfan:master

Conversation

@shinfan

Copy link
Copy Markdown
Contributor

We were wrapping all underlying API exceptions as a transport-agnostic ApiException which makes it hard to catch based on the status code.

To improve the try/catch experience, we now add an individual exception class for each status code.

@codecov-io

codecov-io commented Aug 24, 2017

Copy link
Copy Markdown

Codecov Report

Merging #357 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@ Coverage Diff @@## master #357 +/- ##
=========================================
Coverage 76.63% 76.63% Complexity 495 495 =========================================
Files 114 114 Lines 2542 2542 Branches 185 185 =========================================
Hits 1948 1948 Misses 522 522 Partials 72 72

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f8acadd...d69b3c8. Read the comment docs.

if (statusCode != null) {
assertThat(exception.getCause()).isInstanceOf(GrpcApiException.class);
GrpcApiException cause = (GrpcApiException) exception.getCause();
assertThat(exception.getCause() instanceof ApiException);

This comment was marked as spam.

This comment was marked as spam.

import com.google.api.gax.rpc.ResourceExhaustedApiException;
import com.google.api.gax.rpc.UnauthenticatedApiException;
import com.google.api.gax.rpc.UnavailableApiException;
import com.google.api.gax.rpc.UnknownApiException;

This comment was marked as spam.

This comment was marked as spam.


import com.google.api.core.BetaApi;

/** Represents an aborted exception thrown during an RPC call. */

This comment was marked as spam.

This comment was marked as spam.

@shinfan

Copy link
Copy Markdown
ContributorAuthor

@garrettjonesgoogle PTAL

@garrettjonesgooglegarrettjonesgoogle left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM after my one comment is addressed here.

I'd also like @jabubake to take a look.

return new GrpcDirectCallable<>(FakeMethodDescriptor.<Integer, Operation>create());
}

private void assertExceptionType(GrpcStatusCode code, Throwable exception) {

This comment was marked as spam.

This comment was marked as spam.

@jabubake

Copy link
Copy Markdown

LGTM, this is great.

@shinfan
shinfanforce-pushed the master branch 2 times, most recently from c0f7d58 to d69b3c8CompareAugust 24, 2017 23:47
@shinfan
shinfan merged commit 0f3ff97 into googleapis:masterAug 25, 2017
This was referenced Aug 31, 2017
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@shinfan@codecov-io@jabubake@garrettjonesgoogle