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
Feature Request: Error Translation from gRPC to connect-go
Is your feature request related to a problem? Please describe.
I'm frequently encountering situations where I need to translate google.golang.org/grpc errors to connect-go errors. Currently, there's no straightforward way to do this, which leads to additional development time and potential inconsistencies in error handling across projects that are migrating from gRPC to connect-go.
Describe the solution you'd like
I propose adding a utility function or package within connect-go that can convert gRPC errors to their connect-go equivalents. This could be implemented as:
This function would take a gRPC error as input and return the corresponding connect-go error, maintaining the original error's status code, message, and any additional details.
Describe alternatives you've considered
Creating a separate, third-party package for this conversion. However, this approach may lead to fragmentation and inconsistency across projects using connect-go.
Manually mapping errors in each project that needs this functionality. This is currently the default approach but is time-consuming and error-prone.
Extending the existing connect.CodeOf function to handle gRPC errors directly. While this could work, it might clutter the primary API and could be confusing for users who don't need gRPC compatibility.
The proposed solution of adding a dedicated conversion function or package within connect-go seems to be the most clean and maintainable approach.
Additional context
This feature would greatly benefit projects that are in the process of migrating from gRPC to connect-go, as well as those that need to interact with both gRPC and connect-go services. It would ensure consistent error handling and reduce the cognitive load on developers working with both ecosystems.
The text was updated successfully, but these errors were encountered:
franchb
changed the title
Translate errors grom google.golang.org/errpr to connect-go/error
Translate errors grom google.golang.org/error to connect-go/error
Jul 5, 2024
@franchb, this would require adding a dependency from connect-go to the grpc-go module. That would then pull in lots of gRPC-related packages into every program that uses connect-go.
While one big objective of Connect is to providing support for HTTP 1.1 for web and mobile RPC clients, another is to provide libraries that are lightweight & simple and that use standard (or widely used) libraries and idioms for the target language. So pulling the behemoth that is grpc-go into connect-go's dependency graph is a non-starter.
The recommended way to do this is, in your own codebase (where I assume you are migrating a gRPC codebase to Connect and still have handlers and helpers that produce the gRPC error type), use an interceptor that examines all errors and translates them to Connect errors whenever it sees a gRPC error. This translation should be very straight-forward to do with the existing APIs.
Feature Request: Error Translation from gRPC to connect-go
Is your feature request related to a problem? Please describe.
I'm frequently encountering situations where I need to translate
google.golang.org/grpc
errors toconnect-go
errors. Currently, there's no straightforward way to do this, which leads to additional development time and potential inconsistencies in error handling across projects that are migrating from gRPC to connect-go.Describe the solution you'd like
I propose adding a utility function or package within connect-go that can convert gRPC errors to their connect-go equivalents. This could be implemented as:
connect
package:connect/grpccompat
:This function would take a gRPC error as input and return the corresponding connect-go error, maintaining the original error's status code, message, and any additional details.
Describe alternatives you've considered
Creating a separate, third-party package for this conversion. However, this approach may lead to fragmentation and inconsistency across projects using connect-go.
Manually mapping errors in each project that needs this functionality. This is currently the default approach but is time-consuming and error-prone.
Extending the existing
connect.CodeOf
function to handle gRPC errors directly. While this could work, it might clutter the primary API and could be confusing for users who don't need gRPC compatibility.The proposed solution of adding a dedicated conversion function or package within connect-go seems to be the most clean and maintainable approach.
Additional context
This feature would greatly benefit projects that are in the process of migrating from gRPC to connect-go, as well as those that need to interact with both gRPC and connect-go services. It would ensure consistent error handling and reduce the cognitive load on developers working with both ecosystems.
The text was updated successfully, but these errors were encountered: