utils

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRetryFailed        = errors.New("request failed after all retries") // Wraps the last underlying error
	ErrClientHTTPError    = errors.New("client HTTP error (4xx)")          // Wraps original error/status
	ErrServerHTTPError    = errors.New("server HTTP error (5xx)")          // Wraps original error/status
	ErrOtherHTTPError     = errors.New("other HTTP error (non-2xx)")       // Wraps original error/status
	ErrRobotsDisallowed   = errors.New("disallowed by robots.txt")
	ErrScopeViolation     = errors.New("URL out of scope (domain/prefix/pattern)")
	ErrMaxDepthExceeded   = errors.New("maximum crawl depth exceeded")
	ErrContentSelector    = errors.New("content selector not found")
	ErrParsing            = errors.New("parsing error")    // Wraps specific parsing error (HTML, URL, JSON, XML)
	ErrFilesystem         = errors.New("filesystem error") // Wraps os errors
	ErrDatabase           = errors.New("database error")   // Wraps badger errors
	ErrSemaphoreTimeout   = errors.New("timeout acquiring semaphore")
	ErrRequestCreation    = errors.New("failed to create HTTP request")
	ErrResponseBodyRead   = errors.New("failed to read response body")
	ErrMarkdownConversion = errors.New("failed to convert HTML to markdown")
	ErrConfigValidation   = errors.New("configuration validation error")
	ErrNonHTMLContent     = errors.New("non-HTML content type")
)

--- Sentinel Errors for Categorization ---

Functions

func CalculateFileSHA256

func CalculateFileSHA256(filePath string) (string, error)

CalculateFileSHA256 computes the SHA-256 hash of a file's content.

func CalculateStringSHA256

func CalculateStringSHA256(content string) string

CalculateStringSHA256 computes the SHA-256 hash of a string.

func CategorizeError

func CategorizeError(err error) string

CategorizeError maps an error to a predefined category string for logging/metrics.

func CompileRegexPatterns

func CompileRegexPatterns(patterns []string) ([]*regexp.Regexp, error)

CompileRegexPatterns compiles regex strings into usable *regexp.Regexp objects. Returns an error if any pattern is invalid.

func GenerateAndSaveTreeStructure

func GenerateAndSaveTreeStructure(targetDir, outputFilePath string, log *logrus.Entry) error

GenerateAndSaveTreeStructure walks the targetDir and writes a text-based directory tree structure to the specified outputFilePath

func SanitizeFilename

func SanitizeFilename(name string) string

SanitizeFilename cleans a string to be safe for use as a filename component

Types

This section is empty.

Jump to

Keyboard shortcuts

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