From b674ac21b41526133bf51eefc69af1ce1bf7ce27 Mon Sep 17 00:00:00 2001 From: Sam Alba Date: Thu, 22 Apr 2021 11:56:48 -0700 Subject: [PATCH] cmd/list: better error handling Signed-off-by: Sam Alba --- cmd/dagger/cmd/list.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/cmd/dagger/cmd/list.go b/cmd/dagger/cmd/list.go index c72157a1..28de981d 100644 --- a/cmd/dagger/cmd/list.go +++ b/cmd/dagger/cmd/list.go @@ -70,15 +70,27 @@ func getCurrentDeploymentID(ctx context.Context, store *dagger.Store) string { lg.Warn().Err(err).Msg("cannot get current working directory") return "" } - st, _ := store.LookupDeploymentByPath(ctx, wd) + + st, err := store.LookupDeploymentByPath(ctx, wd) + if err != nil { + // Ignore error + return "" + } + if len(st) == 1 { return st[0].ID } + return "" } func formatPath(p string) string { - usr, _ := user.Current() + usr, err := user.Current() + if err != nil { + // Ignore error + return p + } + dir := usr.HomeDir if strings.HasPrefix(p, dir) {