ref
This commit is contained in:
1 parent
f3934e038e
commit
4fdf7c0ca2
19 files changed
+457
-379
No files matched your search
@@ -0,0 +1,28 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/integration-system/isp-lib/http"
|
||||
"github.com/integration-system/isp-lib/structure"
|
||||
"github.com/valyala/fasthttp"
|
||||
"google.golang.org/grpc/codes"
|
||||
)
|
||||
|
||||
const (
|
||||
JsonContentType = "application/json; charset=utf-8"
|
||||
)
|
||||
|
||||
func SendError(errorMessage string, errorCode codes.Code, details []interface{}, ctx *fasthttp.RequestCtx) {
|
||||
grpcCode := errorCode.String()
|
||||
|
||||
structureError := structure.GrpcError{
|
||||
ErrorMessage: errorMessage,
|
||||
ErrorCode: grpcCode,
|
||||
Details: details,
|
||||
}
|
||||
|
||||
ctx.SetContentType(JsonContentType)
|
||||
ctx.SetStatusCode(http.CodeToHttpStatus(errorCode))
|
||||
msg, _ := json.Marshal(structureError)
|
||||
_, _ = ctx.Write(msg)
|
||||
}
|
||||
Reference in new issue
Block a user