Errors & logging
On this page
Error types and the named structured loggers.
struct ArgumentError
Section titled “struct ArgumentError”type ArgumentError struct {ArgName stringPosition int // -1 when name-onlyDetail string}Description
ArgumentError is returned when a function argument is missing, of the wrong shape, or fails inline validation at bind/init time. Use it from inside OnBind/OnBindTyped to surface a clean error to the caller rather than the generic “RuntimeError: …” default.
Methods
method Error
Section titled “method Error”func (e *ArgumentError) Error() stringError implements the error interface.
struct CatalogReadOnlyError
Section titled “struct CatalogReadOnlyError”type CatalogReadOnlyError struct {Operation string}Description
CatalogReadOnlyError is returned when a write operation is attempted on a read-only catalog.
Methods
method Error
Section titled “method Error”func (e *CatalogReadOnlyError) Error() stringError implements the error interface.
type LogFormat
Section titled “type LogFormat”type LogFormat stringDescription
LogFormat selects the stderr log format.
struct LoggingConfig
Section titled “struct LoggingConfig”type LoggingConfig struct {// Level is the minimum level for enabled loggers. Default Info.Level slog.Level// Format selects the stderr formatter. Default text.Format LogFormat// Output is where records are written. Default os.Stderr.Output io.Writer// Loggers restricts which named loggers emit records. Empty means// "all known loggers". Unknown names are passed through with a warning// on stderr (matching vgi-python's behaviour).Loggers []string// Debug forces Level to Debug regardless of the explicit Level value.// Mirrors vgi-python's --debug shortcut.Debug bool}Description
LoggingConfig describes the desired logging setup for a worker.
Methods
method effectiveLevel
Section titled “method effectiveLevel”func (c LoggingConfig) effectiveLevel() slog.LeveleffectiveLevel returns the level after applying the Debug shortcut.
struct LoggingFlags
Section titled “struct LoggingFlags”type LoggingFlags struct {debug *boollevel *stringformat *stringloggers *stringloggerSet *stringSliceFlag}Description
LoggingFlags holds the values parsed from the standard logging CLI flags. Resolve it into a LoggingConfig with .Config().
Methods
method Apply
Section titled “method Apply”func (lf *LoggingFlags) Apply() errorApply parses, validates, and installs the logging configuration in one step. Convenience wrapper for the common case where a worker main() just wants “honor the flags”.
method Config
Section titled “method Config”func (lf *LoggingFlags) Config() (LoggingConfig, error)Config resolves the parsed flags into a LoggingConfig. Call after fs.Parse(). Returns an error if a flag value is malformed.
function RegisterLoggingFlags
Section titled “function RegisterLoggingFlags”func RegisterLoggingFlags(fs *flag.FlagSet) *LoggingFlagsRegisterLoggingFlags registers –debug, –log-level, –log-format, and –log-logger on the given FlagSet. The returned LoggingFlags resolves to a LoggingConfig after Parse() runs. Env-var defaults: VGI_LOG_LEVEL, VGI_LOG_FORMAT, VGI_LOG_LOGGER. VGI_WORKER_DEBUG=1 enables –debug.
struct SchemaFieldMismatch
Section titled “struct SchemaFieldMismatch”type SchemaFieldMismatch struct {FieldName stringExpected arrow.DataType // nil when missing on the expected sideActual arrow.DataType // nil when missing on the actual sideReason string // optional — overrides the default phrasing}Description
SchemaFieldMismatch is one field-level disagreement between two schemas.
struct SchemaValidationError
Section titled “struct SchemaValidationError”type SchemaValidationError struct {Context string // e.g. "table function output schema"Mismatches []SchemaFieldMismatch}Description
SchemaValidationError describes one or more field-level type mismatches between an expected schema and an actual schema. The message lists each mismatched field with expected vs. actual types — analogous to vgi-python’s SchemaValidationError.
Methods
method Error
Section titled “method Error”func (e *SchemaValidationError) Error() stringError implements the error interface.
struct TypeBoundError
Section titled “struct TypeBoundError”type TypeBoundError struct {ArgName stringPosition intFieldType arrow.DataType// PredicateNames are the runtime-resolved names of the failed predicates,// e.g. ["IsMultipliableType"]. Empty when reflection couldn't recover them.PredicateNames []string}Description
TypeBoundError is returned when an input schema field type does not satisfy the type bound predicates declared for an argument.
Methods
method Error
Section titled “method Error”func (e *TypeBoundError) Error() stringError implements the error interface.
struct UnknownFunctionError
Section titled “struct UnknownFunctionError”type UnknownFunctionError struct {Name stringFunctionType string}Description
UnknownFunctionError is returned when a function name cannot be resolved.
Methods
method Error
Section titled “method Error”func (e *UnknownFunctionError) Error() stringError implements the error interface.
struct WorkerPanicError
Section titled “struct WorkerPanicError”type WorkerPanicError struct {FunctionName stringPhase string // bind, init, process, finalize, etc.Recovered any // value passed to panic()Stack []byte}Description
WorkerPanicError is returned when a registered function panics during bind/init/process/finalize. The dispatcher (see RecoverPanic) catches the panic, captures the stack, and returns this error to the caller so the worker process stays alive and the RPC client sees a clean message.
Methods
method Error
Section titled “method Error”func (e *WorkerPanicError) Error() stringError implements the error interface.
struct loggerFilterHandler
Section titled “struct loggerFilterHandler”type loggerFilterHandler struct {base slog.Handlerenabled map[string]struct{}loggerName string // captured via WithAttrs (slog.With("logger", X))}Description
loggerFilterHandler wraps a base handler and drops records emitted by a named logger (logger=…) that is not in the enabled set. The name is captured when a logger is constructed via slog.New(…).With(“logger”, N), which routes through WithAttrs — we extract and remember the value, and also keep checking the per-record attributes so direct calls like slog.Info(“…”, “logger”, “vgi.foo”) still filter correctly.
Records without any “logger” attribute always pass — they originate from code paths not migrated to the named loggers and we prefer not to silently swallow them.
Methods
method Enabled
Section titled “method Enabled”func (h *loggerFilterHandler) Enabled(ctx context.Context, lvl slog.Level) boolEnabled reports whether the underlying handler is enabled for the level; per-logger filtering happens later, in Handle.
method Handle
Section titled “method Handle”func (h *loggerFilterHandler) Handle(ctx context.Context, r slog.Record) errorHandle drops the record when its logger name is not in the enabled set, otherwise forwards it to the base handler.
method WithAttrs
Section titled “method WithAttrs”func (h *loggerFilterHandler) WithAttrs(attrs []slog.Attr) slog.HandlerWithAttrs returns a copy capturing any “logger” attribute so the name is known when filtering records.
method WithGroup
Section titled “method WithGroup”func (h *loggerFilterHandler) WithGroup(name string) slog.HandlerWithGroup returns a copy with the group applied to the base handler, preserving the captured logger name and enabled set.
method allow
Section titled “method allow”func (h *loggerFilterHandler) allow(name string) boolstruct stringSliceFlag
Section titled “struct stringSliceFlag”type stringSliceFlag struct {values []string}Description
stringSliceFlag is a flag.Value that accumulates repeatable –log-logger values. It also splits a single value on commas, so users can pass either “–log-logger=vgi.catalog –log-logger=vgi.rpc” or “–log-logger=vgi.catalog,vgi.rpc”.
Methods
method Set
Section titled “method Set”func (s *stringSliceFlag) Set(v string) errorSet appends the comma-separated values in v, ignoring blank entries, to implement flag.Value for repeatable string flags.
function AsRpcError
Section titled “function AsRpcError”func AsRpcError(err error) *vgirpc.RpcErrorAsRpcError converts an error to an RpcError for wire transmission. Maps known custom error types to clearer Type strings so DuckDB-side error surfacing matches vgi-python’s behaviour.
function ConfigureLogging
Section titled “function ConfigureLogging”func ConfigureLogging(cfg LoggingConfig)ConfigureLogging installs a fresh root handler reflecting cfg and rebinds the package-level named loggers. Subsequent calls replace the configuration. Safe to call from main() before vgi.NewWorker(…).
function ParseLogLevel
Section titled “function ParseLogLevel”func ParseLogLevel(s string) (slog.Level, error)ParseLogLevel parses a level string (“debug”, “info”, “warn”, “error”, any case). Returns slog.LevelInfo for empty input. Returns an error on unknown values.
function RecoverPanic
Section titled “function RecoverPanic”func RecoverPanic(phase, fnName string, errOut *error)RecoverPanic is meant to be deferred at the top of an RPC handler that may invoke user-supplied function code. On panic it stores a WorkerPanicError into *errOut so the framework returns a clean RpcError instead of crashing.
Usage:
func (w *Worker) handleBind(...) (resp BindResponseWire, err error) {defer vgi.RecoverPanic("bind", req.FunctionName, &err)...}function parentLogger
Section titled “function parentLogger”func parentLogger(name string) stringparentLogger returns the dotted parent of name, or “” at the root. “vgi.catalog” → “vgi”; “vgi” → “”.