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

GrpcError details list is empty on client side #509

Open
balesz opened this issue Jul 26, 2021 · 2 comments
Open

GrpcError details list is empty on client side #509

balesz opened this issue Jul 26, 2021 · 2 comments

Comments

@balesz
Copy link
Contributor

balesz commented Jul 26, 2021

I throw a GrpcError.failedPrecondition error on server side with a GeneratedMessage typed object in the details list. On the client side I get the GrpcError with the proper status code and error message, but the details list is empty.

Proto

syntax = "proto3";
package test;

service Test {
  rpc Test(Empty) returns (Empty);
}

message Empty {
}

message Detail {
  int32 code = 1;
}

Test

import 'package:flutter_test/flutter_test.dart';
import 'package:grpc/grpc.dart';

import 'test.pbgrpc.dart';

void main() {
  test('test', () async {
    await Server([TestService()]).serve(address: "localhost", port: 8080);
    final opts = ChannelOptions(credentials: ChannelCredentials.insecure());
    final channel = ClientChannel('localhost', port: 8080, options: opts);
    try {
      await TestClient(channel).test(Empty());
    } on GrpcError catch (error) {
      expect(error, isA<GrpcError>());
      expect(error.message, equals('ERROR'));
      expect(error.details, isNotEmpty);
    }
  });
}

class TestService extends TestServiceBase {
  @override
  Future<Empty> test(ServiceCall call, Empty request) {
    throw GrpcError.failedPrecondition("ERROR", [Detail(code: 444)]);
  }
}
@mraleph
Copy link
Member

mraleph commented Aug 9, 2021

PR from @acoutts (#349) added deserialization of error details for client size, but nobody contributed serialization of error details for server side so far.

PRs are welcome.

@wolframm
Copy link

Was there any progress on this item?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants