gRPC 2 UNKNOWN vs 11 OUT_OF_RANGE
Both gRPC 2 (UNKNOWN) and 11 (OUT_OF_RANGE) belong to the gRPC Status Codes category. 2 indicates that an unknown error occurred. This may be returned when a server raises an exception that doesn't map to any known gRPC status code. Meanwhile, 11 means that the operation was attempted past the valid range. For example, seeking or reading past the end of a file.
説明
An unknown error occurred. This may be returned when a server raises an exception that doesn't map to any known gRPC status code.
このコードが表示される場合
The server threw an unhandled exception or returned an error that gRPC couldn't classify into a more specific status code.
解決方法
Check the server logs for the underlying exception. Wrap server-side errors with explicit gRPC status codes instead of letting them bubble up as UNKNOWN.
説明
The operation was attempted past the valid range. For example, seeking or reading past the end of a file.
このコードが表示される場合
A pagination offset exceeded the available data, or an iterator moved past the end of a collection. Unlike INVALID_ARGUMENT, this depends on the current state of the data.
解決方法
Check the valid range before making the request. For pagination, use the total count or next-page token to avoid requesting beyond the last page.
主な違い
gRPC 2: An unknown error occurred. This may be returned when a server raises an exception that doesn't map to any known gRPC status code.
gRPC 11: The operation was attempted past the valid range. For example, seeking or reading past the end of a file.
You encounter 2 when the server threw an unhandled exception or returned an error that gRPC couldn't classify into a more specific status code.
You encounter 11 when a pagination offset exceeded the available data, or an iterator moved past the end of a collection. Unlike INVALID_ARGUMENT, this depends on the current state of the data.
どちらをいつ使うか
For 2 (UNKNOWN): Check the server logs for the underlying exception. Wrap server-side errors with explicit gRPC status codes instead of letting them bubble up as UNKNOWN. For 11 (OUT_OF_RANGE): Check the valid range before making the request. For pagination, use the total count or next-page token to avoid requesting beyond the last page.