MCPcopy
hub / github.com/spacecloud-io/space-cloud / formatError

Function formatError

gateway/modules/auth/errors.go:23–39  ·  view source on GitHub ↗

FormatError check whether error is provided in config.Rule

(ctx context.Context, rule *config.Rule, err error)

Source from the content-addressed store, hash-verified

21
22// FormatError check whether error is provided in config.Rule
23func formatError(ctx context.Context, rule *config.Rule, err error) error {
24 if err == nil {
25 return nil
26 }
27
28 name := rule.Name
29 if name == "" {
30 name = "with no name"
31 }
32
33 _ = helpers.Logger.LogError(helpers.GetRequestID(ctx), fmt.Sprintf("Rule (%s) of type (%s) failed", name, rule.Rule), err, map[string]interface{}{})
34
35 if rule.Error == "" {
36 return err
37 }
38 return errors.New(rule.Error)
39}

Callers 12

executeTemplateMethod · 0.85
matchRuleMethod · 0.85
matchFuncMethod · 0.85
matchQueryMethod · 0.85
matchAndMethod · 0.85
matchOrMethod · 0.85
matchFunction · 0.85
matchForceMethod · 0.85
matchRemoveMethod · 0.85
matchEncryptMethod · 0.85
matchDecryptMethod · 0.85
matchHashMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected