From dc837046bf7c388d6f7004ea8180d2348327b4a5 Mon Sep 17 00:00:00 2001 From: mircearoata Date: Sun, 28 Apr 2024 15:34:35 +0200 Subject: [PATCH] chore: remove unnecessary error handling --- cli/disk/ftp.go | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/cli/disk/ftp.go b/cli/disk/ftp.go index e8884c2..c66119c 100644 --- a/cli/disk/ftp.go +++ b/cli/disk/ftp.go @@ -138,15 +138,11 @@ func (l *ftpDisk) existsWithLock(res *puddle.Resource[*ftp.ServerConn], p string } } else { if errors.As(err, &protocolError) { - switch protocolError.Code { - case ftp.StatusFileUnavailable: + if protocolError.Code == ftp.StatusFileUnavailable { return false, nil - default: - // We won't handle any other kind of error, see above. - return false, fmt.Errorf("failed to list path: %w", err) } } - // This is a non-protocol error, see above. + // We won't handle any other kind of error, see above. return false, fmt.Errorf("failed to list path: %w", err) } @@ -168,17 +164,13 @@ func (l *ftpDisk) existsWithLock(res *puddle.Resource[*ftp.ServerConn], p string } if errors.As(err, &protocolError) { - switch protocolError.Code { - case ftp.StatusFileUnavailable: + if protocolError.Code == ftp.StatusFileUnavailable { return false, nil - default: - // We won't handle any other kind of error, see above. - return false, fmt.Errorf("failed to list path: %w", err) } } - // This is a non-protocol error, see above. - return false, fmt.Errorf("failed to list path: %w", err) + // We won't handle any other kind of error, see above. + return false, fmt.Errorf("failed to list parent path: %w", err) } func (l *ftpDisk) Exists(p string) (bool, error) {