error-types

command
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package error-types demonstrates every structured error type in go-codex.

Each section triggers one specific error type, shows how to extract it via errors.As or errors.Is, accesses its typed fields, and logs it with slog so the structured LogValue() output is visible.

Error types covered:

  • codex.TypeMismatchError — wrong Go type passed to a codec
  • codex.ConstraintError — Refine constraint check failed
  • codex.ErrMissingField — required struct field absent from input
  • codex.ValidationError — single field error from struct decode
  • codex.ValidationErrors — all field errors from struct decode
  • codex.ElementError — error at a specific slice index
  • codex.KeyError — error at a specific map key
  • codex.UnknownVariantError — tagged-union discriminator has no matching codec
  • codex.VariantError — known variant's codec failed

Run with: go run ./examples/error-types

Jump to

Keyboard shortcuts

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