-
Notifications
You must be signed in to change notification settings - Fork 273
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
Add decoded grpc-status-details-bin details to GrpcError #349
Conversation
|
I've just added handling to parse the details into the correct GeneratedMessage types and added the required proto / generated files for the typings. You can now handle your errors like this: import 'package:grpc/grpc.dart';
try {
// Some gRPC call
await myCall();
} catch (e) {
/// Handle error details
if (e is GrpcError) {
e.details.forEach((f) {
if (f is BadRequest) {
print('Bad request: ${f.first.fieldViolations.first.description}') // Bad request: The specified forex pair does not exist
}
});
}
} |
… code.proto. Includes status code string name in the error now
…ent from code.proto. Includes status code string name in the error now" This reverts commit e6049a4.
Anyone know why only one of the CI jobs are failing? Dart test and analyze both pass on my system. |
Logs: Passing job in master: https://api.travis-ci.org/v3/job/727680315/log.txt So this is failing because of a resolution issue related to the new |
Example: route guide client cleanup (grpc#350)
Merge master
Thanks! Looks to be all fixed up now after bumping the version for protobuf in the other pubspec files. |
This PR needs at least some basic tests for the added functionality to make sure it works. |
Thanks @mraleph - I've just added in some tests. Let me know if there's anything you think needs deeper testing coverage. The main things in this PR are this:
If there is a failure during deserialization, the fallback is the GrcpError object will just have an empty list for its I've added the protos we use to the project so those can be updated over time, using the included |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. Thank you for the contribution! I have left few comments on the PR.
We are waiting right now on a manual internal-to-external synchronisation to complete (bringing our internal fork of this repo in sync with external). Once that completes and you address the comments - I will approve and merge this PR.
lib/src/client/call.dart
Outdated
if (status != 0) { | ||
_responseError(GrpcError.custom(status, message)); | ||
final status = metadata['grpc-status']; | ||
final statusCode = status != null ? int.parse(status) : 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not clear to me if the check for null
is needed. I think it is an error if it is null at this point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the original author put this check in to ensure we don't try to do int.parse(null)
. Perhaps this is cleaner?
final statusCode = int.parse(status ?? '0');
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean the check below on line 286 (because there was no check here before your change)?
I think the check there was just another way to write _headerMetadata.containsKey('grpc-status')
. It's unclear to me why they choose two inconsistent ways to write it, but I also don't think that this header can even be null
at this point.
(Well, NNBD migration will reveal the truth).
…te protobuf definitions. Moved the regenerate script to the project root tool/ directory.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
README.md
Outdated
@@ -25,3 +25,6 @@ For complete documentation, see [Dart gRPC](https://grpc.io/docs/languages/dart) | |||
If you experience problems or have feature requests, [open an issue](https://github.com/dart-lang/grpc-dart/issues/new). | |||
|
|||
Note that we have limited bandwidth to accept PRs, and that all PRs require signing the [EasyCLA](https://lfcla.com). | |||
|
|||
## Updating protobuf definitions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this better be moved to CONTRIBUTING.md
Thanks @mraleph! Just pushed changes for those final items. |
The CI failures there don't seem related to the changes I've made- seems it failed to install chrome due to a bad checksum. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just two comments left.
I have landed a workaround for the issue with Travis in dd34af2
lib/src/client/call.dart
Outdated
|
||
List<GeneratedMessage> decodeStatusDetails(String data) { | ||
try { | ||
/// Parse each Any type into the correct GeneratedMessage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this comment still applies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I will merge once merging is unblocked.
Just pushed one last change - bumped version in the pubspec to match the changelog entry. |
@mraleph any estimate when merging will be unblocked? |
Earlier today the status update in a different PR was: "We are almost done with internal-to-external sync. So I would expect to be able to merge this by the end of the week (or maybe early next week)" |
Thanks @mit-mit! Shall I try and correct the pubspec version here or leave that for the final merge? |
Let's wait, we might have another PR or two coming which would change versions. I will ping this PR once we are ready to go. |
Hey @mraleph is there any update for this merge? |
We are ready to land. Could you rebase and resolve conflicts? I will merge after that. |
Alright just merge latest master from upstream (were no conflicts), and bumped version to 2.7.0. |
@mraleph the pub package is still at v2.3.0 with last release on 9/21. Master seems to be at v2.7.0. When will the next release be put on pub.dev? |
* Bump SDK version constraint to 2.3 * Add dependency on fixnum package
I am going to publish but I need to address few issues which slipped through testing (and analysis): #377 |
@acoutts 2.7.0 released |
Currently there is no way to access the details of a GrpcError in the Dart implementation. This PR adds the fully-typed details into the dart exception that gets thrown.
This implements what's requested in #209.
cc @jakobr-google as I saw you had a TODO comment in
call.dart
to do this someday.