grpc-dart
grpc-dart copied to clipboard
GrpcError details list is empty on client side
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)]);
}
}
PR from @acoutts (https://github.com/grpc/grpc-dart/pull/349) added deserialization of error details for client size, but nobody contributed serialization of error details for server side so far.
PRs are welcome.
Was there any progress on this item?