File tree Expand file tree Collapse file tree 3 files changed +12
-30
lines changed Expand file tree Collapse file tree 3 files changed +12
-30
lines changed Original file line number Diff line number Diff line change 6
6
} from "@nestjs/common" ;
7
7
import { Observable , throwError } from "rxjs" ;
8
8
import { catchError } from "rxjs/operators" ;
9
- import { GRPC_EXCEPTION_FROM_HTTP } from "../utils" ;
9
+ import { GRPC_CODE_FROM_HTTP } from "../utils" ;
10
+ import { status as Status } from "@grpc/grpc-js" ;
11
+ import { RpcException } from "@nestjs/microservices" ;
10
12
11
13
@Injectable ( )
12
14
export class HttpToGrpcInterceptor implements NestInterceptor {
@@ -32,11 +34,16 @@ export class HttpToGrpcInterceptor implements NestInterceptor {
32
34
message : string ;
33
35
} ;
34
36
35
- if ( ! ( exception . statusCode in GRPC_EXCEPTION_FROM_HTTP ) )
36
- return throwError ( ( ) => err ) ;
37
+ const statusCode =
38
+ GRPC_CODE_FROM_HTTP [ exception . statusCode ] || Status . INTERNAL ;
37
39
38
- const Exception = GRPC_EXCEPTION_FROM_HTTP [ exception . statusCode ] ;
39
- return throwError ( ( ) => new Exception ( exception . message ) ) ;
40
+ return throwError (
41
+ ( ) =>
42
+ new RpcException ( {
43
+ message : exception . message ,
44
+ code : statusCode ,
45
+ } ) ,
46
+ ) ;
40
47
} ) ,
41
48
) ;
42
49
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
export * from "./error-object" ;
2
2
export * from "./http-codes-map" ;
3
- export * from "./grpc-exceptions-map" ;
4
3
export * from "./grpc-codes-map" ;
You can’t perform that action at this time.
0 commit comments