Documentation
¶
Index ¶
Constants ¶
const ( RegistryContextPrefixCachePath = "Cache Path: " RegistryContextPrefixRegistrySource = "Registry Source: " RegistryContextPrefixRegistryName = "Registry Name: " RegistryContextPrefixPackName = "Pack Name: " RegistryContextPrefixRef = "Ref: " )
UIContextPrefix* are the prefixes commonly used to create a string used in UI errors outputs. If a prefix is used more than once, it should have a const created.
const ( UIContextErrorDetail = "Details: " UIContextErrorSuggestion = "Suggestions: " UIContextErrorFilename = "Filename: " UIContextErrorPosition = "Position: " UIContextPrefixGitRegistryURL = "Git Registry URL: " UIContextPrefixPackName = "Pack Name: " UIContextPrefixPackPath = "Pack Path: " UIContextPrefixPackRef = "Pack Ref: " UIContextPrefixTemplateName = "Template Name: " UIContextPrefixJobName = "Job Name: " UIContextPrefixDeploymentName = "Deployment Name: " UIContextPrefixRegion = "Region: " UIContextPrefixHCLRange = "HCL Range: " UIContextPrefixRegistryName = "Registry Name: " UIContextPrefixRegistryPath = "Registry Path: " UIContextPrefixRegistryTarget = "Registry Target: " UIContextPrefixOutputPath = "Output Path: " )
UIContextPrefix* are the prefixes commonly used to create a string used in UI errors outputs. If a prefix is used more than once, it should have a const created.
Variables ¶
var ( ErrCachePathRequired = newError("cache path is required") ErrInvalidCachePath = newError("invalid cache path") ErrInvalidRegistryRevision = newError("invalid revision") ErrInvalidRegistrySource = newError("invalid registry source") ErrNoRegistriesAdded = newError("no registries were added to the cache") ErrPackNameRequired = newError("pack name is required") ErrPackNotFound = newError("pack not found") ErrRegistryNameRequired = newError("registry name is required") ErrRegistryNotFound = newError("registry not found") ErrRegistrySourceRequired = newError("registry source is required") )
var As = stdErrors.As
var ErrNoTemplatesRendered = newError("no templates were rendered by the renderer process run")
ErrNoTemplatesRendered is an error to be used when the CLI runs a render process that doesn't result in parent templates. This helps provide a clear indication to the problem, as I have certainly been confused by this.
var Is = stdErrors.Is
var New = stdErrors.New
var Unwrap = stdErrors.Unwrap
Functions ¶
This section is empty.
Types ¶
type ErrorContext ¶
type ErrorContext struct {
// contains filtered or unexported fields
}
ErrorContext is used to store and manipulate error context strings used to output user-friendly, rich information.
func NewErrorContext ¶
func NewErrorContext() *ErrorContext
NewErrorContext creates an empty ErrorContext.
func (*ErrorContext) Add ¶
func (ctx *ErrorContext) Add(prefix, val string)
Add formats and upserts the passed prefix and value onto the error contexts.
func (*ErrorContext) Append ¶
func (ctx *ErrorContext) Append(context *ErrorContext)
Append takes an existing ErrorContext and appends any context into the current.
func (*ErrorContext) Copy ¶
func (ctx *ErrorContext) Copy() *ErrorContext
Copy to currently stored contexts into a new ErrorContext.
func (*ErrorContext) GetAll ¶
func (ctx *ErrorContext) GetAll() []string
GetAll returns all the stored context strings.
func (*ErrorContext) String ¶
func (ctx *ErrorContext) String() string
String returns the stored contexts as a minimally formatted string.
type PackTemplateError ¶
type PackTemplateError struct { Filename string // template filename returned Line int // the line in the template if found StartChar int // the character number in the template if found EndChar int // the character number calculated as the end if an "at" is found Err error // the last element in given error text when split by ": " Details string // some additional help text for specific known error patterns Suggestions []string // some suggestions to add to the error context Extra []string // remaining splits between the beginning elements and the last one which is the error // contains filtered or unexported fields }
PackTemplateErrors are designed to progressively enhance the errors returned from go template rendering. Implements `error`
func ParseTemplateError ¶
func ParseTemplateError(tplCtx parser.PackTemplateContext, err error) *PackTemplateError
ParseTemplateError returns a PackTemplate error that wraps and attempts to enhance errors returned from go template.
func (PackTemplateError) Error ¶
func (p PackTemplateError) Error() string
Error implements the `error` interface using a value receiver so it works with PackTemplateError values or pointers.
func (*PackTemplateError) ToWrappedUIContext ¶
func (p *PackTemplateError) ToWrappedUIContext() *WrappedUIContext
ToWrappedUIContext converts a PackTemplateError into a WrappedUIContext for display to the CLI
type UIErrorContext ¶
type UIErrorContext struct {
// contains filtered or unexported fields
}
UIErrorContext is used to store and manipulate error context strings used by the CLI to output user-friendly, rich information.
func NewUIErrorContext ¶
func NewUIErrorContext() *UIErrorContext
NewUIErrorContext creates an empty UIErrorContext.
func (*UIErrorContext) Add ¶
func (u *UIErrorContext) Add(prefix, val string)
Add formats and upserts the passed prefix and value onto the error contexts.
func (*UIErrorContext) Append ¶
func (u *UIErrorContext) Append(context *UIErrorContext)
Append takes an existing UIErrorContext and appends any context into the current.
func (*UIErrorContext) Copy ¶
func (u *UIErrorContext) Copy() *UIErrorContext
Copy to currently stored contexts into a new UIErrorContext.
func (*UIErrorContext) GetAll ¶
func (u *UIErrorContext) GetAll() []string
GetAll returns all the stored context strings.
func (*UIErrorContext) String ¶
func (u *UIErrorContext) String() string
String returns the stored contexts as a minimally formatted string.
type WrappedUIContext ¶
type WrappedUIContext struct { // Err is the full error message to store. Err error // Subject is a short, high-level summary of the error. It should avoid // including complex formatting to include file names for example. These // items should be added to the Context instead. Subject string // Context contains all the context required to fully understand the error // and helps troubleshooting. Context *UIErrorContext }
WrappedUIContext encapsulates an error, subject, and context that can be used to provide detail error outputs to the console. It is suggested that any function returning an error to the CLI use this instead of a standard error.
func HCLDiagsToWrappedUIContext ¶
func HCLDiagsToWrappedUIContext(diags hcl.Diagnostics) []*WrappedUIContext
HCLDiagsToWrappedUIContext converts HCL specific hcl.Diagnostics into an array of WrappedUIContext.
func (*WrappedUIContext) Error ¶
func (w *WrappedUIContext) Error() string
Error is used to satisfy to builtin.Error interface. This allows us to use WrappedUIContext as an error if needed, although we should prefer to return the strong type.