Help us shape the future of Go! Take the 2026 Go Developer Survey

fserrors

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package fserrors maps filesystem errnos to codemeld's canonical error-category vocabulary.

OP_FAIL formatting, control-character collapse, and the stderr fallback channel for un-renderable errors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollapseControls

func CollapseControls(s string) string

CollapseControls replaces newlines, carriage returns, and tabs with single spaces, then collapses runs of spaces to one, yielding a single line.

func FormatOpFail

func FormatOpFail(operation, targetPath string, cat Category) string

FormatOpFail returns the canonical OP_FAIL line:

codemeld: <operation> failed: <target_path>: <error_category>

operation and targetPath are run through CollapseControls; the result has no trailing newline.

func WriteToStderr

func WriteToStderr(operation, targetPath string, cat Category, detail string)

WriteToStderr is the single chokepoint for errors that cannot be rendered in the TUI. It writes the OP_FAIL line and an optional collapsed detail continuation to os.Stderr. It does not call os.Exit, so the caller chooses the exit code.

Types

type Category

type Category string
const (
	PermissionDenied Category = "permission_denied"
	NoSpace          Category = "no_space"
	ReadOnlyFS       Category = "read_only_fs"
	IOError          Category = "io_error"
	NotFound         Category = "not_found"
	InUse            Category = "in_use"
)

func CategorizeErrno

func CategorizeErrno(err error) Category

CategorizeErrno extracts a wrapped syscall.Errno from err and maps it to a Category. Unknown errnos and nil-wrapped errors return IOError.

Jump to

Keyboard shortcuts

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