feat: 0.0.1
This commit is contained in:
146 files changed
+10444
No files matched your search
@@ -0,0 +1,24 @@
|
||||
package gapi
|
||||
|
||||
import (
|
||||
"google.golang.org/genproto/googleapis/rpc/errdetails"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
func fieldViolation(field string, err error) *errdetails.BadRequest_FieldViolation {
|
||||
return &errdetails.BadRequest_FieldViolation{
|
||||
Field: field,
|
||||
Description: err.Error(),
|
||||
}
|
||||
}
|
||||
|
||||
func invalidArgumentError(violations []*errdetails.BadRequest_FieldViolation) error {
|
||||
badRequest := &errdetails.BadRequest{FieldViolations: violations}
|
||||
stInvalid := status.New(codes.InvalidArgument, "invalid user request")
|
||||
stDetails, err := stInvalid.WithDetails(badRequest)
|
||||
if err != nil {
|
||||
return stInvalid.Err()
|
||||
}
|
||||
return stDetails.Err()
|
||||
}
|
||||
Reference in new issue
Block a user