MCPcopy
hub / github.com/peak/s5cmd / printError

Function printError

command/error.go:31–86  ·  view source on GitHub ↗

printError is the helper function to log error messages.

(command, op string, err error)

Source from the content-addressed store, hash-verified

29
30// printError is the helper function to log error messages.
31func printError(command, op string, err error) {
32 // dont print cancelation errors
33 if errorpkg.IsCancelation(err) {
34 return
35 }
36
37 // check if we have our own error type
38 {
39 cerr, ok := err.(*errorpkg.Error)
40 if ok {
41 msg := log.ErrorMessage{
42 Err: cleanupError(cerr.Err),
43 Command: cerr.FullCommand(),
44 Operation: cerr.Op,
45 }
46 log.Error(msg)
47 return
48 }
49 }
50
51 // check if errors are aggregated
52 {
53 merr, ok := err.(*multierror.Error)
54 if ok {
55 for _, err := range merr.Errors {
56 customErr, ok := err.(*errorpkg.Error)
57 if ok {
58 msg := log.ErrorMessage{
59 Err: cleanupError(customErr.Err),
60 Command: customErr.FullCommand(),
61 Operation: customErr.Op,
62 }
63 log.Error(msg)
64 continue
65 }
66
67 msg := log.ErrorMessage{
68 Err: cleanupError(err),
69 Command: command,
70 Operation: op,
71 }
72
73 log.Error(msg)
74 }
75 return
76 }
77 }
78
79 // we don't know the exact error type. log the error as is.
80 msg := log.ErrorMessage{
81 Err: cleanupError(err),
82 Command: command,
83 Operation: op,
84 }
85 log.Error(msg)
86}
87
88// cleanupError converts multiline messages into

Callers 15

NewCopyCommandFunction · 0.85
NewCopyFunction · 0.85
RunMethod · 0.85
NewPresignCommandFunction · 0.85
RunMethod · 0.85
NewMakeBucketCommandFunction · 0.85
RunMethod · 0.85
NewRemoveBucketCommandFunction · 0.85
RunMethod · 0.85
NewHeadCommandFunction · 0.85
RunMethod · 0.85
NewSyncCommandFunction · 0.85

Calls 3

ErrorFunction · 0.92
cleanupErrorFunction · 0.85
FullCommandMethod · 0.80

Tested by

no test coverage detected