From 56406702943f8e6bdf0d7c1e7ba7dc4a5343729e Mon Sep 17 00:00:00 2001 From: rajibkuet07 Date: Fri, 7 Jun 2024 15:19:26 +0600 Subject: [PATCH] fix(interceptor): fix rpc exception message in http to grpc interceptor Handles all sorts of http exceptions from rpc client. No need to use extra try catch for parse error in grpc to http interceptor. Refs: #13 Refs: #14 --- lib/interceptors/http-to-grpc.interceptor.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/interceptors/http-to-grpc.interceptor.ts b/lib/interceptors/http-to-grpc.interceptor.ts index 16dccdd..743db14 100644 --- a/lib/interceptors/http-to-grpc.interceptor.ts +++ b/lib/interceptors/http-to-grpc.interceptor.ts @@ -40,7 +40,12 @@ export class HttpToGrpcInterceptor implements NestInterceptor { return throwError( () => new RpcException({ - message: exception.message, + message: JSON.stringify({ + error: exception.message, + type: + typeof exception.message === "string" ? "string" : "object", + exceptionName: RpcException.name, + }), code: statusCode, }), );