gRPC 2 UNKNOWN vs 5 NOT_FOUND
Both gRPC 2 (UNKNOWN) and 5 (NOT_FOUND) 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, 5 means that some requested entity was not found. For example, a file or directory that the RPC was supposed to operate on does not exist.
คำอธิบาย
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.
คำอธิบาย
Some requested entity was not found. For example, a file or directory that the RPC was supposed to operate on does not exist.
เมื่อคุณพบเห็น
The resource referenced in the request doesn't exist — such as looking up a user by ID that has been deleted or never created.
วิธีแก้ไข
Verify the resource identifier is correct. Ensure the resource was created before accessing it, or handle the not-found case gracefully in your client.
ความแตกต่างหลัก
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 5: Some requested entity was not found. For example, a file or directory that the RPC was supposed to operate on does not exist.
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 5 when the resource referenced in the request doesn't exist — such as looking up a user by ID that has been deleted or never created.
ควรใช้อันไหนเมื่อไร
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 5 (NOT_FOUND): Verify the resource identifier is correct. Ensure the resource was created before accessing it, or handle the not-found case gracefully in your client.