chore: Better user friendly error messages (#64)

This commit is contained in:
Abhisek Datta
2025-08-21 18:26:05 +05:30
committed by GitHub
parent cd306884e3
commit 2493fb4dc6
16 changed files with 555 additions and 56 deletions
+40 -7
View File
@@ -1,15 +1,48 @@
package packagemanager
import (
"errors"
"github.com/safedep/pmg/usefulerror"
)
var (
ErrPackageNotFound = errors.New("package not found")
ErrFailedToFetchPackage = errors.New("failed to fetch package")
ErrFailedToParsePackage = errors.New("failed to parse package")
ErrNoPackagesFound = errors.New("no packages found")
ErrAuthorNotFound = errors.New("author not found")
ErrPackageNotFound = usefulerror.Useful().
WithCode("package_not_found").
WithHumanError("The requested package could not be found.").
WithHelp("Please check the package name and try again.")
ErrGitHubRateLimitExceeded = errors.New("github api rate limit exceeded")
ErrFailedToFetchPackage = usefulerror.Useful().
WithCode("fetch_failed").
WithHumanError("Failed to retrieve the requested package.").
WithHelp("Check your network connection and try again. If the problem persists, the package repository may be temporarily unavailable.").
Msg("failed to fetch package")
ErrFailedToResolveVersion = usefulerror.Useful().
WithCode("resolve_version_failed").
WithHumanError("Failed to resolve the requested package version.").
WithHelp("Check your network connection and try again. If the problem persists, the package repository may be temporarily unavailable.").
Msg("failed to resolve package version")
ErrFailedToResolveDependencies = usefulerror.Useful().
WithCode("resolve_failed").
WithHumanError("Failed to resolve dependencies.").
WithHelp("Check your network connection and try again. If the problem persists, the package repository may be temporarily unavailable.").
Msg("failed to resolve dependencies")
ErrFailedToParsePackage = usefulerror.Useful().
WithCode("parse_failed").
WithHumanError("The package data could not be processed.").
WithHelp("The package may be corrupted or in an unsupported format.").
Msg("failed to parse package")
ErrAuthorNotFound = usefulerror.Useful().
WithCode("author_not_found").
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")
ErrGitHubRateLimitExceeded = usefulerror.Useful().
WithCode("github_rate_limit").
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")
)