Skip to content

Commit

Permalink
Merge pull request #8 from zphtet/no-content-exception
Browse files Browse the repository at this point in the history
added grpc-no-content-exception
  • Loading branch information
mohsenbostan authored Mar 19, 2024
2 parents ddb0a14 + 4c4a38f commit d023256
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/exceptions/no-content.exception.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { status } from "@grpc/grpc-js";
import { RpcException } from "@nestjs/microservices";
import { errorObject } from "../utils";

export class GrpcNoContentException extends RpcException {
constructor(error: string | object) {
super(errorObject(error, status.NO_CONTENT));
}
}
2 changes: 2 additions & 0 deletions lib/utils/http-codes-map.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable prettier/prettier */
import { status as Status } from "@grpc/grpc-js";
import { HttpStatus } from "@nestjs/common";

Expand All @@ -19,4 +20,5 @@ export const HTTP_CODE_FROM_GRPC: Record<number, number> = {
[Status.UNAVAILABLE]: HttpStatus.NOT_FOUND,
[Status.DATA_LOSS]: HttpStatus.INTERNAL_SERVER_ERROR,
[Status.UNAUTHENTICATED]: HttpStatus.UNAUTHORIZED,
[Status.NO_CONTENT]: HttpStatus.NO_CONTENT,
};

0 comments on commit d023256

Please sign in to comment.