Correctly handle nil error in verbose logging (fixes #1921)
This commit is contained in:
parent
197bfa9f11
commit
ef6f52f688
@ -102,12 +102,11 @@ func (s *verboseSvc) formatEvent(ev events.Event) string {
|
|||||||
return fmt.Sprintf("Started syncing %q / %q (%v %v)", data["folder"], data["item"], data["action"], data["type"])
|
return fmt.Sprintf("Started syncing %q / %q (%v %v)", data["folder"], data["item"], data["action"], data["type"])
|
||||||
case events.ItemFinished:
|
case events.ItemFinished:
|
||||||
data := ev.Data.(map[string]interface{})
|
data := ev.Data.(map[string]interface{})
|
||||||
if err := data["error"]; err != nil {
|
if err, ok := data["error"].(*string); ok && err != nil {
|
||||||
// If the err interface{} is not nil, it is a string pointer.
|
// If the err interface{} is not nil, it is a string pointer.
|
||||||
// Dereference it to get the actual error or Sprintf will print
|
// Dereference it to get the actual error or Sprintf will print
|
||||||
// the pointer value....
|
// the pointer value....
|
||||||
errStr := *err.(*string)
|
return fmt.Sprintf("Finished syncing %q / %q (%v %v): %v", data["folder"], data["item"], data["action"], data["type"], *err)
|
||||||
return fmt.Sprintf("Finished syncing %q / %q (%v %v): %v", data["folder"], data["item"], data["action"], data["type"], errStr)
|
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("Finished syncing %q / %q (%v %v): Success", data["folder"], data["item"], data["action"], data["type"])
|
return fmt.Sprintf("Finished syncing %q / %q (%v %v): Success", data["folder"], data["item"], data["action"], data["type"])
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user