apperr

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package apperr defines AST-Digger's custom error types and the exit code taxonomy used to translate errors into process exit codes.

It corresponds to ast_digger/error.py in the Python implementation, with the addition of an exit code mapping (design_GOLANG.md, "エラーハンドリング" section) since Go does not have a shared exception hierarchy that a CLI entry point can inspect the way Python's does.

Index

Constants

View Source
const (
	// ExitOK indicates successful completion.
	ExitOK = 0
	// ExitInternalError indicates an unclassified internal error.
	ExitInternalError = 1
	// ExitCLIParamError indicates invalid CLI parameters/flags.
	ExitCLIParamError = 2
	// ExitFileAccessError indicates a file access error (see FileAccessError).
	ExitFileAccessError = 3
	// ExitSymbolNotFoundError indicates a symbol lookup failure (see
	// SymbolNotFoundError).
	ExitSymbolNotFoundError = 4
	// ExitDatabaseCorruptedError indicates a database corruption/schema
	// mismatch that persisted after automatic recovery (see
	// DatabaseCorruptedError).
	ExitDatabaseCorruptedError = 5
)

Exit codes for the CLI, per the exit code taxonomy defined in design_GOLANG.md ("終了コードのタクソノミー").

Variables

This section is empty.

Functions

func ExitCode

func ExitCode(err error) int

ExitCode maps err to the process exit code defined by the taxonomy in design_GOLANG.md. A nil err maps to ExitOK. Errors that are not one of the custom types defined in this package map to ExitInternalError; CLI parameter validation errors (ExitCLIParamError) are expected to be detected and reported directly by the CLI layer (cobra flag validation) rather than via a value returned from this package.

Types

type DatabaseCorruptedError

type DatabaseCorruptedError struct {
	// Path is the database file path, if known.
	Path string
	// Err is the underlying error, if any.
	Err error
}

DatabaseCorruptedError indicates that the SQLite cache database was corrupted or had a mismatched schema. It corresponds to Python's ast_digger.error.DatabaseCorruptedError.

func (*DatabaseCorruptedError) Error

func (e *DatabaseCorruptedError) Error() string

func (*DatabaseCorruptedError) Unwrap

func (e *DatabaseCorruptedError) Unwrap() error

Unwrap allows errors.Is / errors.As to see through to the underlying error.

type FileAccessError

type FileAccessError struct {
	// Path is the file path that could not be accessed, if known.
	Path string
	// Err is the underlying error, if any (e.g. from the os package).
	Err error
}

FileAccessError indicates that a target file could not be accessed, read, or was of an unsupported type. It corresponds to Python's ast_digger.error.FileAccessError.

func (*FileAccessError) Error

func (e *FileAccessError) Error() string

func (*FileAccessError) Unwrap

func (e *FileAccessError) Unwrap() error

Unwrap allows errors.Is / errors.As to see through to the underlying error.

type SymbolNotFoundError

type SymbolNotFoundError struct {
	// FilePath is the file that was searched.
	FilePath string
	// SymbolPath is the symbol path that could not be resolved.
	SymbolPath string
	// Suggestions holds candidate symbol names (up to 5) that exist in the
	// file, for inclusion in the error message (F-10, task 14).
	Suggestions []string
}

SymbolNotFoundError indicates that a requested symbol path could not be found within a file. It corresponds to Python's ast_digger.error.SymbolNotFoundError.

func (*SymbolNotFoundError) Error

func (e *SymbolNotFoundError) Error() string

Jump to

Keyboard shortcuts

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