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
+18
-17
@@ -1,7 +1,8 @@
|
||||
package packagemanager
|
||||
|
||||
import (
|
||||
"github.com/safedep/pmg/usefulerror"
|
||||
"github.com/safedep/dry/usefulerror"
|
||||
"github.com/safedep/pmg/errcodes"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -12,44 +13,44 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
ErrPackageNotFound = usefulerror.Useful().
|
||||
WithCode(usefulerror.ErrCodeNotFound).
|
||||
ErrPackageNotFound = usefulerror.NewUsefulError().
|
||||
WithCode(errcodes.NotFound).
|
||||
WithHumanError("The requested package could not be found.").
|
||||
WithHelp("Please check the package name and try again.")
|
||||
|
||||
ErrFailedToFetchPackage = usefulerror.Useful().
|
||||
WithCode(usefulerror.ErrCodeNetwork).
|
||||
ErrFailedToFetchPackage = usefulerror.NewUsefulError().
|
||||
WithCode(errcodes.Network).
|
||||
WithHumanError("Failed to retrieve the requested package.").
|
||||
WithHelp("Check your network connection and try again.").
|
||||
Msg("failed to fetch package")
|
||||
WithMsg("failed to fetch package")
|
||||
|
||||
ErrFailedToResolveVersion = usefulerror.Useful().
|
||||
WithCode(usefulerror.ErrCodeNetwork).
|
||||
ErrFailedToResolveVersion = usefulerror.NewUsefulError().
|
||||
WithCode(errcodes.Network).
|
||||
WithHumanError("Failed to resolve the requested package version.").
|
||||
WithHelp("Check your network connection and try again.").
|
||||
Msg("failed to resolve package version")
|
||||
WithMsg("failed to resolve package version")
|
||||
|
||||
ErrFailedToResolveDependencies = usefulerror.Useful().
|
||||
ErrFailedToResolveDependencies = usefulerror.NewUsefulError().
|
||||
WithCode(errDependencyResolutionFailed).
|
||||
WithHumanError("Failed to resolve dependencies.").
|
||||
WithHelp("Check your network connection and try again.").
|
||||
Msg("failed to resolve dependencies")
|
||||
WithMsg("failed to resolve dependencies")
|
||||
|
||||
ErrFailedToParsePackage = usefulerror.Useful().
|
||||
ErrFailedToParsePackage = usefulerror.NewUsefulError().
|
||||
WithCode(errPackageParseFailed).
|
||||
WithHumanError("The package data could not be processed.").
|
||||
WithHelp("The package may be corrupted or in an unsupported format.").
|
||||
Msg("failed to parse package")
|
||||
WithMsg("failed to parse package")
|
||||
|
||||
ErrAuthorNotFound = usefulerror.Useful().
|
||||
ErrAuthorNotFound = usefulerror.NewUsefulError().
|
||||
WithCode(errPackageAuthorNotFound).
|
||||
WithHumanError("The package author information could not be found.").
|
||||
WithHelp("This may be due to incomplete package metadata or network issues.").
|
||||
Msg("author not found")
|
||||
WithMsg("author not found")
|
||||
|
||||
ErrGitHubRateLimitExceeded = usefulerror.Useful().
|
||||
ErrGitHubRateLimitExceeded = usefulerror.NewUsefulError().
|
||||
WithCode(errGitHubRateLimitExceeded).
|
||||
WithHumanError("GitHub API rate limit has been exceeded.").
|
||||
WithHelp("Wait for the rate limit to reset or configure authentication to increase your rate limit.").
|
||||
Msg("github api rate limit exceeded")
|
||||
WithMsg("github api rate limit exceeded")
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user