From c0f2c1d8717979a3326ebf7c01bf305e04ab7ed3 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 7 Feb 2021 21:09:00 +0100 Subject: [PATCH] ls: Check for non-nil error before calling panic() --- cmd/restic/cmd_ls.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/restic/cmd_ls.go b/cmd/restic/cmd_ls.go index 90106e8a5..5ab1a4693 100644 --- a/cmd/restic/cmd_ls.go +++ b/cmd/restic/cmd_ls.go @@ -165,7 +165,9 @@ func runLs(opts LsOptions, gopts GlobalOptions, args []string) error { ShortID: sn.ID().Str(), StructType: "snapshot", }) - panic(err) + if err != nil { + Warnf("JSON encode failed: %v\n", err) + } } printNode = func(path string, node *restic.Node) { @@ -182,7 +184,9 @@ func runLs(opts LsOptions, gopts GlobalOptions, args []string) error { ChangeTime: node.ChangeTime, StructType: "node", }) - panic(err) + if err != nil { + Warnf("JSON encode failed: %v\n", err) + } } } else { printSnapshot = func(sn *restic.Snapshot) {