Skip to content

Commit 5640670

Browse files
committed
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: mohsenbostan#13 Refs: mohsenbostan#14
1 parent 3dc7a0f commit 5640670

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/interceptors/http-to-grpc.interceptor.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ export class HttpToGrpcInterceptor implements NestInterceptor {
4040
return throwError(
4141
() =>
4242
new RpcException({
43-
message: exception.message,
43+
message: JSON.stringify({
44+
error: exception.message,
45+
type:
46+
typeof exception.message === "string" ? "string" : "object",
47+
exceptionName: RpcException.name,
48+
}),
4449
code: statusCode,
4550
}),
4651
);

0 commit comments

Comments
 (0)