refactor : Refactor error handling to use dry/usefulerror (#283)

* update the go.sum

Signed-off-by: DivyanshuVortex <divyanshuchandra9027@gmail.com>

* migrate most of the files to dry errors

Signed-off-by: DivyanshuVortex <divyanshuchandra9027@gmail.com>

* update the rest of the files

Signed-off-by: DivyanshuVortex <divyanshuchandra9027@gmail.com>

* fixs the review comments

Signed-off-by: DivyanshuVortex <divyanshuchandra9027@gmail.com>

* chores

Signed-off-by: DivyanshuVortex <divyanshuchandra9027@gmail.com>

---------

Signed-off-by: DivyanshuVortex <divyanshuchandra9027@gmail.com>
Co-authored-by: Abhisek Datta <abhisek.datta@gmail.com>
This commit is contained in:
Divyanshu
2026-05-24 12:22:19 +05:30
committed by GitHub
co-authored by Abhisek Datta
parent e5fe0df82e
commit 20e01d5cae
33 changed files with 234 additions and 639 deletions
+4 -3
View File
@@ -8,7 +8,8 @@ import (
"strings"
"testing"
"github.com/safedep/pmg/usefulerror"
"github.com/safedep/dry/usefulerror"
"github.com/safedep/pmg/errcodes"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@@ -99,7 +100,7 @@ func TestProfileDiffUnknownProfile(t *testing.T) {
assert.Contains(t, err.Error(), "no-such-profile-xyz")
usefulErr, ok := usefulerror.AsUsefulError(err)
require.True(t, ok, "diff error should expose a UsefulError through Unwrap")
assert.Equal(t, usefulerror.ErrCodeNotFound, usefulErr.Code())
assert.Equal(t, errcodes.NotFound, usefulErr.Code())
}
func TestProfileDiffUnknownDriver(t *testing.T) {
@@ -113,7 +114,7 @@ func TestProfileDiffUnknownDriver(t *testing.T) {
assert.Contains(t, err.Error(), "unknown driver")
usefulErr, ok := usefulerror.AsUsefulError(err)
require.True(t, ok, "diff error should expose a UsefulError through Unwrap")
assert.Equal(t, usefulerror.ErrCodeInvalidArgument, usefulErr.Code())
assert.Equal(t, errcodes.InvalidArgument, usefulErr.Code())
}
func TestProfileDiffMissingProfileShowsUsage(t *testing.T) {