errors

package
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoChanges = NewAppError(TypeGit, "No staged changes detected", nil).
					WithSuggestion("Stage your changes first with: git add <files>")

	ErrGetBranch = NewAppError(TypeGit, "Failed to get current branch", nil).
					WithSuggestion("Make sure you are in a git repository: git status")

	ErrNoBranch = NewAppError(TypeGit, "No branch detected", nil).
				WithSuggestion("Create a branch first: git checkout -b <branch-name>")

	ErrGetRepoRoot = NewAppError(TypeGit, "Failed to get repository root", nil).
					WithSuggestion("Make sure you are inside a git repository")

	ErrGetRepoURL = NewAppError(TypeGit, "Failed to get repository URL", nil).
					WithSuggestion("Add a remote: git remote add origin <url>")

	ErrGetCommits = NewAppError(TypeGit, "Failed to get commits", nil).
					WithSuggestion("Make sure you have commits in your repository: git log")

	ErrGetCommitCount = NewAppError(TypeGit, "Failed to get commit count", nil)

	ErrGetRecentCommits = NewAppError(TypeGit, "Failed to get recent commit messages", nil).
						WithSuggestion("Verify repository has commits: git log --oneline")

	ErrAddFile = NewAppError(TypeGit, "Failed to add file to staging", nil).
				WithSuggestion("Check if the file exists and you have write permissions")

	ErrExtractRepoInfo = NewAppError(TypeGit, "Failed to extract repository info", nil)

	ErrCreateTag = NewAppError(TypeGit, "Failed to create tag", nil).
					WithSuggestion("Make sure the tag doesn't already exist: git tag -l")

	ErrPushTag = NewAppError(TypeGit, "Failed to push tag", nil).
				WithSuggestion("Check your remote connection: git remote -v")

	ErrPush = NewAppError(TypeGit, "Failed to push to remote", nil).
			WithSuggestion("Verify remote is configured: git remote -v")

	ErrFetchTags = NewAppError(TypeGit, "Failed to fetch tags from remote", nil).
					WithSuggestion("Check your network connection and remote access")

	ErrCreateCommit = NewAppError(TypeGit, "Failed to create commit", nil).
					WithSuggestion("Ensure git user is configured:\n   git config --global user.name \"Your Name\"\n   git config --global user.email \"your@email.com\"")

	ErrGetDiff = NewAppError(TypeGit, "Failed to get diff", nil).
				WithSuggestion("Check if you have staged changes: git status")

	ErrNoDiff = NewAppError(TypeGit, "No differences detected", nil).
				WithSuggestion("Stage your changes first: git add <files>")

	ErrInvalidBranch = NewAppError(TypeGit, "Must be on main or master branch to create releases", nil).
						WithSuggestion("Switch to main branch: git checkout main")

	ErrTagNotFound = NewAppError(TypeGit, "Tag not found in repository history", nil).
					WithSuggestion("List available tags: git tag -l")

	ErrInvalidTagFormat = NewAppError(TypeGit, "Tag does not match semver format (vX.Y.Z)", nil).
						WithSuggestion("Use semantic versioning format: v1.0.0, v2.1.3, etc.")

	ErrValidateTag = NewAppError(TypeGit, "Failed to validate tag existence", nil)

	ErrGetChangedFiles = NewAppError(TypeGit, "Failed to get changed files", nil).
						WithSuggestion("Verify you have staged changes: git status")

	ErrGetTagDate = NewAppError(TypeGit, "Failed to get tag date", nil)

	ErrGetGitUser = NewAppError(TypeGit, "Failed to get git user configuration", nil).
					WithSuggestion("Configure git user:\n   git config --global user.name \"Your Name\"\n   git config --global user.email \"your@email.com\"")

	ErrGitUserNotConfigured = NewAppError(TypeGit, "git user.name not configured", nil).
							WithSuggestion("Set your git username: git config --global user.name \"Your Name\"")

	ErrGitEmailNotConfigured = NewAppError(TypeGit, "git user.email not configured", nil).
								WithSuggestion("Set your git email: git config --global user.email \"your@email.com\"")

	ErrNotInGitRepo = NewAppError(TypeGit, "Not in a git repository", nil).
					WithSuggestion("Initialize a git repository: git init")
)

Git errors

View Source
var (
	ErrAPIKeyMissing = NewAppError(TypeConfiguration, "AI API key is missing", nil).
						WithSuggestion("Run: matecommit config init --quick")

	ErrTokenMissing = NewAppError(TypeConfiguration, "VCS Token is missing", nil).
					WithSuggestion("Configure GitHub token: matecommit config init --full")

	ErrConfigMissing = NewAppError(TypeConfiguration, "Configuration is missing", nil).
						WithSuggestion("Initialize configuration: matecommit config init")
)

Configuration errors

View Source
var (
	ErrRepositoryNotFound = NewAppError(TypeVCS, "repository not found", nil).
							WithSuggestion("Check repository URL and access permissions")

	ErrVCSNotSupported = NewAppError(TypeVCS, "VCS provider not supported", nil).
						WithSuggestion("Currently only GitHub is supported")

	ErrCreateRelease = NewAppError(TypeVCS, "failed to create release", nil).
						WithSuggestion("Check your GitHub token has 'repo' permissions")

	ErrUpdateRelease = NewAppError(TypeVCS, "failed to update release", nil).
						WithSuggestion("Verify the release exists: gh release list")

	ErrGetRelease = NewAppError(TypeVCS, "failed to get release", nil).
					WithSuggestion("List available releases: gh release list")

	ErrUploadAsset = NewAppError(TypeVCS, "failed to upload release asset", nil).
					WithSuggestion("Check file exists and is readable")
)

VCS errors

View Source
var (
	ErrGitHubTokenInvalid = NewAppError(TypeVCS, "GitHub token is invalid or expired", nil).
							WithSuggestion("Generate a new token at: https://github.com/settings/tokens\nThen run: matecommit config init --full")

	ErrGitHubInsufficientPerms = NewAppError(TypeVCS, "GitHub token has insufficient permissions", nil).
								WithSuggestion("Token needs 'repo' and 'workflow' scopes.\nRegenerate at: https://github.com/settings/tokens")

	ErrGitHubRateLimit = NewAppError(TypeVCS, "GitHub API rate limit exceeded", nil).
						WithSuggestion("Wait a few minutes or use a personal access token for higher limits")
)

GitHub/VCS specific errors

View Source
var (
	ErrQuotaExceeded = NewAppError(TypeAI, "AI quota exceeded or rate limited", nil).
						WithSuggestion("Wait a few minutes and try again, or check your API quota")

	ErrAIGeneration = NewAppError(TypeAI, "AI generation failed", nil).
					WithSuggestion("Try again or check your API key configuration")

	ErrInvalidAIOutput = NewAppError(TypeAI, "invalid AI output format", nil).
						WithSuggestion("This is likely a temporary issue, please try again")
)

AI errors

View Source
var (
	ErrGeminiAPIKeyInvalid = NewAppError(TypeAI, "Gemini API key is invalid", nil).
							WithSuggestion("Get a valid API key at: https://makersuite.google.com/app/apikey\nThen run: matecommit config init --quick")

	ErrGeminiQuotaExceeded = NewAppError(TypeAI, "Gemini API quota exceeded", nil).
							WithSuggestion("Wait for quota to reset or upgrade your Gemini plan")
)

Gemini/AI specific errors

View Source
var (
	ErrBuildNoVersion  = NewAppError(TypeInternal, "Build version not specified", nil)
	ErrBuildNoCommit   = NewAppError(TypeInternal, "Build commit not specified", nil)
	ErrBuildNoBuildDir = NewAppError(TypeInternal, "Build directory not specified", nil)
	ErrBuildNoDate     = NewAppError(TypeInternal, "Build date not specified", nil)
	ErrBuildFailed     = NewAppError(TypeInternal, "Build operation failed", nil).
						WithSuggestion("Check build logs for compilation errors or missing dependencies")
	ErrVersionFileNotFound = NewAppError(TypeInternal, "Version file not found", nil).
							WithSuggestion("Specify version file in config: matecommit config set version_file <path>")
)
View Source
var (
	ErrUpdateFailed = NewAppError(TypeUpdate, "Failed to update application", nil).
		WithSuggestion("Try manual update from: https://github.com/thomas-vilte/matecommit/releases")
)

Update errors

Functions

This section is empty.

Types

type AppError

type AppError struct {
	Type       ErrorType
	Message    string
	Context    map[string]interface{}
	Err        error
	Suggestion string
}

AppError represents a domain-level error with a type and an underlying error

func NewAppError

func NewAppError(t ErrorType, msg string, err error) *AppError

NewAppError creates a new AppError

func (*AppError) Error

func (e *AppError) Error() string

func (*AppError) Unwrap

func (e *AppError) Unwrap() error

func (*AppError) WithContext

func (e *AppError) WithContext(key string, value interface{}) *AppError

WithContext creates a new AppError with additional context

func (*AppError) WithError

func (e *AppError) WithError(err error) *AppError

WithError creates a new AppError with an underlying error

func (*AppError) WithSuggestion added in v1.6.0

func (e *AppError) WithSuggestion(suggestion string) *AppError

type ErrorType

type ErrorType string

ErrorType defines the category of the error

const (
	TypeConfiguration ErrorType = "CONFIGURATION"
	TypeAI            ErrorType = "AI"
	TypeVCS           ErrorType = "VCS"
	TypeGit           ErrorType = "GIT"
	TypeInternal      ErrorType = "INTERNAL"
	TypeUpdate        ErrorType = "UPDATE"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL