MCPcopy
hub / github.com/ContainerSSH/ContainerSSH / wrapWithMessage

Function wrapWithMessage

config/error.go:16–44  ·  view source on GitHub ↗
(err error, option string, message string, args ...interface{})

Source from the content-addressed store, hash-verified

14}
15
16func wrapWithMessage(err error, option string, message string, args ...interface{}) error {
17 if err == nil {
18 return nil
19 }
20 var typedErr *configError
21 if errors.As(err, &typedErr) {
22 if message == "" {
23 message = typedErr.message
24 } else {
25 message = fmt.Sprintf(message, args...)
26 }
27 return &configError{
28 message: message,
29 optionPath: append([]string{option}, typedErr.optionPath...),
30 cause: err,
31 }
32 } else {
33 if message == "" {
34 message = err.Error()
35 } else {
36 message = fmt.Sprintf(message, args...) + " (" + err.Error() + ")"
37 }
38 return &configError{
39 message: message,
40 optionPath: []string{option},
41 cause: err,
42 }
43 }
44}
45
46func wrap(err error, option string) error {
47 return wrapWithMessage(err, option, "")

Callers 8

validateClientCertMethod · 0.85
ValidateMethod · 0.85
ValidateMethod · 0.85
ValidateMethod · 0.85
ValidateMethod · 0.85
ValidateMethod · 0.85
ValidateMethod · 0.85
wrapFunction · 0.85

Calls 1

ErrorMethod · 0.65

Tested by

no test coverage detected