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
Copy file name to clipboardExpand all lines: docs/errors.md
+57-17Lines changed: 57 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,8 @@
2
2
3
3
Connect uses a standard set of error codes to indicate what went wrong with an RPC. Each error includes a `Code`, a human-readable message, and optionally some typed error details. This document explains how to work with errors in connect-python.
4
4
5
+
For streaming RPCs, error handling has some special considerations - see the [streaming documentation](streaming.md) for details. You can also attach error information to headers and trailers - see the [headers and trailers documentation](headers-and-trailers.md).
6
+
5
7
## Error codes
6
8
7
9
Connect defines 16 error codes. Each code maps to a specific HTTP status code when using the Connect protocol over HTTP. The full list of codes is available in the `connectrpc.code.Code` enum:
@@ -74,14 +76,14 @@ When a client receives an error response, the client stub raises a `ConnectError
1.**Type mismatch**: If `Unpack()` returns `False`, the message type doesn't match. Check the `type_url` to see the actual type.
244
+
245
+
2.**Missing proto imports**: Ensure you've imported the correct protobuf message classes for the error details you expect to receive.
246
+
247
+
3.**Custom error details**: If using custom protobuf messages for error details, ensure both client and server have access to the same proto definitions.
248
+
209
249
### Common error detail types
210
250
211
251
You can use any protobuf message type for error details. Some commonly used types include:
@@ -251,7 +291,7 @@ raise ConnectError(
251
291
252
292
## Error handling in interceptors
253
293
254
-
Interceptors can catch and transform errors. This is useful for adding context, converting error types, or implementing retry logic:
294
+
Interceptors can catch and transform errors. This is useful for adding context, converting error types, or implementing retry logic. For more details on interceptors, see the [interceptors documentation](interceptors.md):
0 commit comments