Trouble retrieving gRPC error details in gRPC-web client

I’m working on a project that uses gRPC-web for communication between the client (written in JavaScript) and the server. I’m having difficulties retrieving error details from the gRPC response on the client side.

Could someone guide me on the correct approach or library for retrieving error details from a gRPC response in a gRPC-web client, specifically when using the grpc-web-client library?

Any help or suggestions would be greatly appreciated. Thank you!

What I Tried:
I attempted to retrieve error details from gRPC metadata in my gRPC-web client. The error details are present in the metadata as a string. Here’s a simplified version of my client code:

const detailsBase64 = error.metadata['grpc-status-details-bin'];
const detailsBinary = atob(detailsBase64);
const uint8Array = new Uint8Array(detailsBinary.length);
for (let i = 0; i < detailsBinary.length; ++i) {
  uint8Array[i] = detailsBinary.charCodeAt(i);
}
const myProto = MyProto.deserializeBinary(uint8Array);

What I Expected:
I expected that by accessing the metadata, I would be able to retrieve the error details.

What Actually Resulted:
When attempting to access the metadata and retrieve the error details, I encountered issues during deserialization. The error details retrieved from the metadata as a string could not be deserialized properly, resulting in an error. The specific error message or type of deserialization issue is Error: Assertion failed.