runerr

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package runerr defines the runtime error raised while evaluating a request file: templates, queries, filters, predicates and captures.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	Span   syntax.Span
	Kind   Kind
	Assert bool

	Name         string
	Actual       string
	Expected     string
	TypeMismatch bool
	Value        string
	Reason       string
}

Error is a runtime error at a source span. Assert is set when the error was raised while evaluating an assert, which makes it an assert failure rather than a runtime error for the exit code.

func New

func New(span syntax.Span, k Kind, assert bool) *Error

New returns an error of kind k at span.

func (*Error) Description

func (e *Error) Description() string

Description is the error title.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Message

func (e *Error) Message() string

Message is the explanation shown under the source line.

func (*Error) Render

func (e *Error) Render(filename, content string, entryLine int) string

Render formats the error for display: the description, the location, the first line of the entry when it is not the error line (entryLine 0 omits it), the source line and the message, all with a line-number gutter.

func (*Error) RenderColor

func (e *Error) RenderColor(filename, content string, entryLine int) string

RenderColor is Render with ANSI colors: a blue gutter, the entry line in gray and the message in red (a body diff in red and green).

type Kind

type Kind int

Kind identifies a runtime error. The comment of each kind names the Error fields it uses.

const (
	// AssertFailure: Actual, Expected, TypeMismatch.
	AssertFailure Kind = iota
	// ExpressionInvalidType: Actual (value repr), Expected (expected kind).
	ExpressionInvalidType
	// FileReadAccess: Value (path).
	FileReadAccess
	// UnauthorizedFileAccess: Value (path).
	UnauthorizedFileAccess
	// FilterDecode: Value (encoding).
	FilterDecode
	// FilterDateParsing: Value (date), Reason (format).
	FilterDateParsing
	// FilterInvalidEncoding: Value (encoding).
	FilterInvalidEncoding
	// FilterInvalidInputValue: Reason.
	FilterInvalidInputValue
	// FilterInvalidInputType: Actual, Expected (kind names).
	FilterInvalidInputType
	// FilterInvalidFormatSpecifier: Value (format).
	FilterInvalidFormatSpecifier
	// FilterMissingInput: no field.
	FilterMissingInput
	// HTTP is an error decoding the response: Value (description), Reason (message).
	HTTP
	// InvalidJSON: Value.
	InvalidJSON
	// InvalidRegex: no field.
	InvalidRegex
	// InvalidURL: Value (URL), Reason.
	InvalidURL
	// InvalidXPathEval: no field.
	InvalidXPathEval
	// NoQueryResult: no field.
	NoQueryResult
	// QueryHeaderNotFound: no field.
	QueryHeaderNotFound
	// QueryInvalidJSON: no field.
	QueryInvalidJSON
	// QueryInvalidJSONPath: Value (expression).
	QueryInvalidJSONPath
	// QueryInvalidXML: no field.
	QueryInvalidXML
	// UndefinedVariable: Value (name).
	UndefinedVariable
	// Unrenderable: Value (display of the value).
	Unrenderable
	// AssertStatus: Actual (status code).
	AssertStatus
	// AssertVersion: Actual (HTTP version).
	AssertVersion
	// AssertHeaderValue: Actual (header value).
	AssertHeaderValue
	// AssertBodyValue: Actual (body text).
	AssertBodyValue
	// AssertBodyDiff: Reason (first diff hunk, one "+"/"-"/" " prefixed
	// line per body line), Value (line of the body start, decimal).
	AssertBodyDiff
	// InvalidOptionValue: Name, Value, Reason.
	InvalidOptionValue
	// NoFilterResult: no field.
	NoFilterResult
	// PossibleLoggedSecret: no field.
	PossibleLoggedSecret
	// UnsupportedSecretType: Actual (kind of the value).
	UnsupportedSecretType
	// FileWriteAccess: Value (path), Reason.
	FileWriteAccess
	// BinaryOutput: no field.
	BinaryOutput
	// ContractViolation: Reason, Name (instance path, optional), Value
	// (spec pointer, optional).
	ContractViolation

	// KindCount is the number of kinds; new kinds go above it.
	KindCount
)

Runtime error kinds.

Jump to

Keyboard shortcuts

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