From c8e997f3fdd187eb1096f1e0f0257e532ee6c24a Mon Sep 17 00:00:00 2001 From: mi-wada Date: Wed, 8 Jan 2025 15:12:14 +0900 Subject: [PATCH] fix(loadt): Fix a bug that overwrote the original error Previously, the existing error (`err`) was overwritten by the new error returned from `runn.RemoveCacheDir()`. This change uses `errors.Join(err, ...)` to merge both errors and ensure the original context is not lost. As a result of this bug, even if the operation failed when the `--threshold` flag was passed, no error was returned (exit with 0). --- cmd/loadt.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/loadt.go b/cmd/loadt.go index f70e2a6f..7758f295 100644 --- a/cmd/loadt.go +++ b/cmd/loadt.go @@ -62,7 +62,7 @@ var loadtCmd = &cobra.Command{ } defer func() { if !flgs.RetainCacheDir { - err = errors.Join(runn.RemoveCacheDir()) + err = errors.Join(err, runn.RemoveCacheDir()) } }()