mirror of
https://github.com/safedep/pmg.git
synced 2026-08-03 07:24:09 +02:00
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:
co-authored by
Abhisek Datta
parent
e5fe0df82e
commit
20e01d5cae
@@ -7,7 +7,8 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/safedep/pmg/sandbox"
|
||||
"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"
|
||||
)
|
||||
@@ -61,7 +62,7 @@ func TestWrapCommandExecutionErrorDoesNotAttributeFailureToSandbox(t *testing.T)
|
||||
|
||||
usefulErr, ok := usefulerror.AsUsefulError(err)
|
||||
require.True(t, ok)
|
||||
assert.Equal(t, usefulerror.ErrCodePackageManagerExecutionFailed, usefulErr.Code())
|
||||
assert.Equal(t, errcodes.PackageManagerExecutionFailed, usefulErr.Code())
|
||||
assert.Equal(t, "Package manager command exited with code: 1", usefulErr.HumanError())
|
||||
assert.NotContains(t, usefulErr.Help(), "./.env")
|
||||
assert.Contains(t, usefulErr.AdditionalHelp(), "pmg sandbox violations list")
|
||||
@@ -76,7 +77,7 @@ func TestWrapCommandExecutionErrorOmitsBreadcrumbWhenNoViolations(t *testing.T)
|
||||
|
||||
usefulErr, ok := usefulerror.AsUsefulError(err)
|
||||
require.True(t, ok)
|
||||
assert.Equal(t, usefulerror.ErrCodePackageManagerExecutionFailed, usefulErr.Code())
|
||||
assert.Equal(t, errcodes.PackageManagerExecutionFailed, usefulErr.Code())
|
||||
assert.NotContains(t, usefulErr.AdditionalHelp(), "pmg sandbox violations list")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user