gRPC

gRPC 0 OK vs 2 UNKNOWN

Both gRPC 0 (OK) and 2 (UNKNOWN) belong to the gRPC Status Codes category. 0 indicates that the operation completed successfully. Not an error; returned on success. Meanwhile, 2 means 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.

0 OK
gRPC

Mô tả

The operation completed successfully. Not an error; returned on success.

Khi bạn thấy mã này

The RPC completed without any issues. This is the expected response for every successful gRPC call.

Cách khắc phục

No fix needed — this indicates everything worked correctly.

Mô tả

An unknown error occurred. This may be returned when a server raises an exception that doesn't map to any known gRPC status code.

Khi bạn thấy mã này

The server threw an unhandled exception or returned an error that gRPC couldn't classify into a more specific status code.

Cách khắc phục

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.

Sự khác biệt chính

1.

gRPC 0: The operation completed successfully. Not an error; returned on success.

2.

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.

3.

You encounter 0 when the RPC completed without any issues. This is the expected response for every successful gRPC call.

4.

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.

Khi nào dùng cái nào

For 0 (OK): No fix needed — this indicates everything worked correctly. 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.

Tìm hiểu thêm