compositeerrors

package
v0.19.950 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package compositeerrors defines the typed, embedded error abstraction used across the Nuon platform.

A CompositeError is a regular Go error (it satisfies the standard error interface) plus typed metadata — a discriminator, a severity, and an optional list of structured Sections — that lets the dashboard present a rich, opinionated view without losing the ability to be returned through the call stack like any other error.

Composite errors are persisted by attaching a CompositeErrorData JSONB column to owner rows (component builds, sandbox runs, deploys, action runs, ..)

New typed errors are added by writing a struct that implements CompositeError in its own subpackage (e.g. compositeerrors/terraform/, compositeerrors/validation/).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompositeError

type CompositeError interface {
	error // headline — the one-line message users see

	Type() Type
	Severity() Severity

	// Sections returns optional structured detail (what / why / fix).
	// Returning nil is fine — the headline alone is a valid view.
	Sections() []Section
}

CompositeError is a typed, structured error. Implementations satisfy the standard error interface (Error() returns the headline message), plus metadata used to persist and present the error in the dashboard.

type CompositeErrorData

type CompositeErrorData struct {
	Type     Type            `json:"type"`
	Severity Severity        `json:"severity"`
	Message  string          `json:"message"`
	Sections []Section       `json:"sections,omitempty"`
	Data     json.RawMessage `json:"data"`
}

CompositeErrorData is the JSONB GORM column attached to owner rows. It captures a typed CompositeError's payload along with its headline message and structured sections, all frozen at write time.

To use, add this to a GORM model struct:

CompositeError *compositeerrors.CompositeErrorData `json:"composite_error,omitempty" gorm:"type:jsonb"`

func New

New constructs a CompositeErrorData from a typed CompositeError. The implementation's data, headline message, and sections are captured at this point, all are frozen on the resulting record.

func (CompositeErrorData) GormDataType

func (CompositeErrorData) GormDataType() string

GormDataType tells GORM to use a jsonb column.

func (*CompositeErrorData) Scan

func (c *CompositeErrorData) Scan(value any) error

Scan implements database/sql.Scanner.

func (*CompositeErrorData) Value

func (c *CompositeErrorData) Value() (driver.Value, error)

Value implements driver.Valuer.

type Section

type Section struct {
	Heading string `json:"heading"`
	Body    string `json:"body"`
}

Section is a heading + body attached to a CompositeError.

type Severity

type Severity string

Severity controls how the dashboard presents an error.

const (
	SeverityFatal   Severity = "fatal"
	SeverityError   Severity = "error"
	SeverityWarning Severity = "warning"
	SeverityInfo    Severity = "info"
)

type Type

type Type string

Type is the discriminator string for a CompositeError implementation (e.g. "terraform.error", "validation").

Jump to

Keyboard shortcuts

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