代码拉取完成,页面将自动刷新
package graphql
import (
"github.com/sensu/sensu-go/backend/apid/actions"
"github.com/sensu/sensu-go/backend/apid/graphql/schema"
"github.com/sensu/sensu-go/cli/client"
"github.com/sensu/sensu-go/graphql"
)
var _ schema.StandardErrorFieldResolvers = (*stdErrImpl)(nil)
var _ graphql.InterfaceTypeResolver = (*errImpl)(nil)
type stdErr struct {
code schema.ErrCode
input string
message string
}
func newStdErr(input string, err error) stdErr {
out := stdErr{code: schema.ErrCodes.ERR_INTERNAL, input: input}
switch terr := err.(type) {
case client.APIError:
out.message = terr.Message
out.code = mapServiceErrCode(terr.Code)
case error:
out.message = err.Error()
}
return out
}
func mapServiceErrCode(code uint32) schema.ErrCode {
switch code {
case uint32(actions.NotFound):
return schema.ErrCodes.ERR_NOT_FOUND
case uint32(actions.AlreadyExistsErr):
return schema.ErrCodes.ERR_ALREADY_EXISTS
case uint32(actions.InternalErr):
fallthrough
default:
return schema.ErrCodes.ERR_INTERNAL
}
}
func wrapInputErrors(input string, errs ...error) []stdErr {
out := make([]stdErr, 0, len(errs))
for _, err := range errs {
if err == nil {
continue
}
out = append(out, newStdErr(input, err))
}
return out
}
//
// Implement StandardError
//
type stdErrImpl struct{}
func (stdErrImpl) Input(p graphql.ResolveParams) (string, error) {
record := p.Source.(stdErr)
return record.input, nil
}
func (stdErrImpl) Code(p graphql.ResolveParams) (schema.ErrCode, error) {
record := p.Source.(stdErr)
return record.code, nil
}
func (stdErrImpl) Message(p graphql.ResolveParams) (string, error) {
record := p.Source.(stdErr)
return record.message, nil
}
func (stdErrImpl) IsTypeOf(record interface{}, _ graphql.IsTypeOfParams) bool {
_, ok := record.(stdErr)
return ok
}
//
// Implement Error
//
type errImpl struct{}
func (errImpl) ResolveType(obj interface{}, _ graphql.ResolveTypeParams) *graphql.Type {
switch obj.(type) {
case stdErr:
return &schema.StandardErrorType
}
return nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。