Some checks failed
CI / Lint (push) Successful in -27m59s
CI / Test (1.25) (push) Successful in -27m46s
CI / Test (1.24) (push) Failing after 59s
CI / Build (push) Successful in -28m14s
Integration Tests / Integration Tests (push) Failing after -28m16s
Release / Build and Release (push) Successful in 1m1s
feat(templ): ✨ added templ to command line that reads go template and outputs code Reviewed-on: #1 Co-authored-by: Hein <hein.puth@gmail.com> Co-committed-by: Hein <hein.puth@gmail.com>
51 lines
1.2 KiB
Go
51 lines
1.2 KiB
Go
package template
|
|
|
|
import "fmt"
|
|
|
|
// TemplateError represents an error that occurred during template operations
|
|
type TemplateError struct {
|
|
Phase string // "load", "parse", "execute"
|
|
Message string
|
|
Err error
|
|
}
|
|
|
|
// Error implements the error interface
|
|
func (e *TemplateError) Error() string {
|
|
if e.Err != nil {
|
|
return fmt.Sprintf("template %s error: %s: %v", e.Phase, e.Message, e.Err)
|
|
}
|
|
return fmt.Sprintf("template %s error: %s", e.Phase, e.Message)
|
|
}
|
|
|
|
// Unwrap returns the wrapped error
|
|
func (e *TemplateError) Unwrap() error {
|
|
return e.Err
|
|
}
|
|
|
|
// NewTemplateLoadError creates a new template load error
|
|
func NewTemplateLoadError(msg string, err error) *TemplateError {
|
|
return &TemplateError{
|
|
Phase: "load",
|
|
Message: msg,
|
|
Err: err,
|
|
}
|
|
}
|
|
|
|
// NewTemplateParseError creates a new template parse error
|
|
func NewTemplateParseError(msg string, err error) *TemplateError {
|
|
return &TemplateError{
|
|
Phase: "parse",
|
|
Message: msg,
|
|
Err: err,
|
|
}
|
|
}
|
|
|
|
// NewTemplateExecuteError creates a new template execution error
|
|
func NewTemplateExecuteError(msg string, err error) *TemplateError {
|
|
return &TemplateError{
|
|
Phase: "execute",
|
|
Message: msg,
|
|
Err: err,
|
|
}
|
|
}
|