Returning status 400 in gRPC with go

753 Views Asked by At

I am used to write Rest API endpoints, wherein we insert error codes like 400 directly in the response.

return new ResponseEntity<>(HttpStatus.BAD_REQUEST);

I have a piece of golang code(part of gRPC API) returning an error, like:

status.Errorf(codes.FailedPrecondition, ...custom error)

How do we map it to status 400?

0

There are 0 best solutions below