MCPcopy Create free account
hub / github.com/bytebase/bytebase / convertErrToStatus

Function convertErrToStatus

backend/api/v1/audit.go:872–895  ·  view source on GitHub ↗

expect 1. connect.Error 2. other unknown errors

(err error)

Source from the content-addressed store, hash-verified

870// 1. connect.Error
871// 2. other unknown errors
872func convertErrToStatus(err error) *spb.Status {
873 if err == nil {
874 return nil
875 }
876 var connectErr *connect.Error
877 if !errors.As(err, &connectErr) {
878 return &spb.Status{
879 Code: int32(codes.Unknown),
880 Message: err.Error(),
881 }
882 }
883
884 st := &spb.Status{
885 Code: int32(connectErr.Code()),
886 Message: connectErr.Message(),
887 }
888 for _, detail := range connectErr.Details() {
889 st.Details = append(st.Details, &anypb.Any{
890 TypeUrl: detail.Type(),
891 Value: detail.Bytes(),
892 })
893 }
894 return st
895}

Callers 1

createAuditLogMethod · 0.85

Calls 2

ErrorMethod · 0.45
TypeMethod · 0.45

Tested by

no test coverage detected