Skip to content

Commit

Permalink
fix(interceptor): fix rpc exception message in http to grpc interceptor
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rajibkuet07 committed Jun 7, 2024
1 parent 3dc7a0f commit 5640670
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/interceptors/http-to-grpc.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}),
);
Expand Down

0 comments on commit 5640670

Please sign in to comment.