diagnostics

package
v1.0.0-alpha.18 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: Apache-2.0 Imports: 2 Imported by: 1

Documentation

Overview

Package diagnostics defines the portable structured reporting model shared by Ferret runtimes and tooling.

Diagnostics contain universal source values and user-facing reporting details. Runtime and compiler implementations may retain richer internal error causes, but those implementation-specific causes are intentionally not part of this package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Annotation

type Annotation struct {
	Range   source.Range `json:"range"`
	Message string       `json:"message"`
	Primary bool         `json:"primary"`
}

Annotation describes one highlighted source range associated with a diagnostic. Message may be empty when the range needs no separate label.

type Diagnostic

type Diagnostic struct {
	Kind        Kind          `json:"kind"`
	Message     string        `json:"message"`
	Source      source.Source `json:"source"`
	Annotations []Annotation  `json:"annotations"`
	Hint        string        `json:"hint"`
	Note        string        `json:"note"`
}

Diagnostic describes one portable structured issue reported by a runtime or tool. It intentionally carries no implementation-specific error cause.

type Diagnostics

type Diagnostics []Diagnostic

Diagnostics is an ordered portable collection of Diagnostic values. It is the error-bearing diagnostic type, including for failures with one item.

func (Diagnostics) Err

func (d Diagnostics) Err() error

Err returns nil for an empty collection and the collection otherwise. The returned concrete error is Diagnostics, so wrapped diagnostic failures can be detected with errors.As into a Diagnostics value.

func (Diagnostics) Error

func (d Diagnostics) Error() string

Error returns a concise summary derived from the collection.

type Kind

type Kind string

Kind classifies a diagnostic. It is open so diagnostic producers can use domain-specific kinds without changing the universal API.

const (
	Unknown         Kind = ""
	Unsupported     Kind = "Unsupported"
	UnexpectedError Kind = "UnexpectedError"
	TypeError       Kind = "TypeError"
)

Shared diagnostic kinds. Producers may define additional Kind values in their owning packages.

func (Kind) String

func (k Kind) String() string

String returns the diagnostic kind as text.

Jump to

Keyboard shortcuts

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