cinzelerror

package
v0.7.0 Latest Latest
Warning

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

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

Documentation

Overview

Copyright 2026 YLD Limited SPDX-License-Identifier: Apache-2.0 Package cinzelerror provides structured error types and sentinel errors for the cinzel CLI. It wraps HCL diagnostic errors into standard Go errors and attaches "open issue" guidance to user-facing messages.

Index

Constants

View Source
const (
	OpenIssue string = "if you think this is incorrect, consider opening an issue in https://www.github.com/yldio/cinzel/issues"
)

OpenIssue is the message appended to errors suggesting users file a bug report.

Variables

View Source
var (
	ErrWorkflowFilenameRequired = errWorkflowFilenameRequired()
	ErrOnlyHclFiles             = errOnlyHclFiles()
	ErrOnRestriction            = errOnRestriction()
	ErrSecretsRestriction       = errSecretsRestriction()
	ErrWorkflowEmptyOn          = errWorkflowEmptyOn()
	ErrOpenIssue                = errOpenIssue()
)

Sentinel errors for workflow and HCL validation.

Functions

func ErrJobEmptySteps

func ErrJobEmptySteps(jobId string) error

ErrJobEmptySteps returns an error indicating the job has no steps.

func ErrWorkflowEmptyJobs

func ErrWorkflowEmptyJobs(workflowId string) error

ErrWorkflowEmptyJobs returns an error indicating the workflow has no jobs.

func IsUserInput added in v0.7.0

func IsUserInput(err error) bool

IsUserInput reports whether err, or anything it wraps, is marked.

func ProcessHCLDiags

func ProcessHCLDiags(diags hcl.Diagnostics) error

ProcessHCLDiags converts HCL diagnostics into a single joined error.

A diagnostic's summary stands in when it carries no detail. Only the detail used to be collected, so a summary-only diagnostic left nothing to join and errors.Join returned nil, which the caller printed as "%!w(<nil>)" with the report-an-issue line after it and no sign of what was actually wrong.

func SafeForTerminal added in v0.6.0

func SafeForTerminal(s string) string

SafeForTerminal rewrites the control characters in s as escaped text.

Errors quote names taken from the input file, and a name is free to carry an ANSI escape sequence. Written to a terminal as they are, those sequences are acted on rather than shown: a crafted job name can recolour the output, erase the line naming the file at fault, or move the cursor to forge a second message. Newline and tab are left alone because the YAML decoder quotes the offending source across several lines, and carriage return is not, because it returns to the start of a line already written.

Only control characters are touched, so a name in any language reads as written.

func UserInput added in v0.7.0

func UserInput(err error) error

UserInput marks err as caused by what was written, not by a defect in cinzel. New leaves the open-an-issue line off these: a duplicate label or a misspelled attribute is the author's to fix, and pointing them at the issue tracker over it wasted their time and ours.

Wrapping a sentinel at its declaration carries the mark through every fmt.Errorf("%w") built on it, and leaves errors.Is comparisons against that sentinel working unchanged.

Types

type Error

type Error struct {
	Err error
}

Error wraps an underlying error with additional context and issue-reporting guidance.

func New

func New(err error, messages ...string) Error

New creates an Error from err and optional context messages, appending the OpenIssue text.

func NewFromResource

func NewFromResource(err error, resourceType string, resourceId string) Error

NewFromResource creates an Error annotated with the resource type and identifier.

func (*Error) Error

func (e *Error) Error() string

Error returns the string representation of the wrapped error.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the underlying error.

Jump to

Keyboard shortcuts

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