You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The generated service client has a signature of Layer[Throwable, GreeterClient]
The generated methods have signatures of ZIO[GreeterClient, io.grpc.Status, examples.greeter.Response]
This results in widening the error type to Any
I've worked around this by using mapError to map io.grpc.Status into a Throwable
The text was updated successfully, but these errors were encountered:
What would be the expected change to resolve this? Possibly one of:
Fix the client example to demonstrate the types in play and how to use mapError to get back to throwables.
Change the generated code to use StatusException instead of Status?
I found during development that indicating failure seemed cleaner using Status rather than an exception, but that was a personal preference. Agree it looks like it can get in the way when combined with other code that can fail with an arbitraryThrowable.
FWIW, using mapError(_.asException) (or mapError(_.asRuntimeException)) would be the simplest way right now to map it into a subclass of Throwable.
The layer uses Throwable, generated service calls use Status and your application/domain code may use a third type.
I think that usage with domain code implies a need for either Throwable or a domain specific type, so the layer and generated service calls should align "out of the box" and not widen to Any. My first inclination would be to pick Status, but I assume the layer uses Throwable for a reason.
Thanks for the tip on asException and asRuntimeException. At least I don't have to define my own subclass of Throwable.
Using example client project:
The generated service client has a signature of
Layer[Throwable, GreeterClient]
The generated methods have signatures of
ZIO[GreeterClient, io.grpc.Status, examples.greeter.Response]
This results in widening the error type to
Any
I've worked around this by using
mapError
to mapio.grpc.Status
into aThrowable
The text was updated successfully, but these errors were encountered: