ni / grpc-labview

gRPC client and server support for LabVIEW
MIT License
91 stars 62 forks source link

Handling gRPC exceptions by gRPC Labview #363

Open Franky-86 opened 5 months ago

Franky-86 commented 5 months ago

Since gRPC-exceptions are the recommended way of handling errors in gRPC, I'd like to use that rather than adding a status field to every response message.

Generated exceptions from server (e.g. C# implementation) can be handled by Labview client. But what about the other way around? How to send exceptions from Labview Server to clients.

AB#2778642

jasonmreding commented 3 months ago

It is up to each gRPC language plugin to handle errors in a style that makes the most sense for that language. An error in this case is an RPC where the response status code is anything other than OK. For a LabVIEW client, that means the status code and details string from the response will get converted to an error cluster. For a C# client, that means a RpcException will get thrown. If you are adding your own error fields to the messages defined in the .proto file, then you are effectively bypassing the built in error reporting of gRPC.

If this is what you are doing, then in general I would say don't do that. If you are doing that because you find the built in error reporting somewhat limited, that's a valid criticism. In fact that's what has led to a "richer error model" that has been adopted as an ad hoc convention by many languages. However, grpc-labview doesn't currently provide any libraries/APIs that makes adopting a rich error model easy. See here for more information about these concepts.