Repository: helm/helm
File: pkg/engine/engine.go (Go)

Code before:
	if t.location != "" {
		_, _ = fmt.Fprintf(&errorString, "%s\n  ", t.location)
	}
	if t.executedFunction != "" {
		_, _ = fmt.Fprintf(&errorString, "%s\n    ", t.executedFunction)
	}
	if t.message != "" {
		_, _ = fmt.Fprintf(&errorString, "%s\n", t.message)
	}
	return errorString.String()
}

// parseTemplateExecErrorString parses a template execution error string from text/template
// without using regular expressions. It returns a TraceableError and true if parsing succeeded.
func parseTemplateExecErrorString(s string) (TraceableError, bool) {
	const prefix = "template: "
	if !strings.HasPrefix(s, prefix) {
		return TraceableError{}, false
	}
	remainder := s[len(prefix):]

	// Special case: "template: no template %q associated with template %q"
	// Matches https://cs.opensource.google/go/go/+/refs/tags/go1.23.6:src/text/template/exec.go;l=191
	traceableError, done := parseTemplateNoTemplateError(s, remainder)
	if done {
		return traceableError, done
	}

	// Executing form: "<templateName>: executing \"<funcName>\" at <<location>>: <errMsg>[ template:...]"
	// Matches https://cs.opensource.google/go/go/+/refs/tags/go1.23.6:src/text/template/exec.go;l=141
	traceableError, done = parseTemplateExecutingAtErrorType(remainder)
	if done {
		return traceableError, done
	}

	// Simple form: "<templateName>: <errMsg>"
	// Use LastIndex to avoid splitting colons within line:col info.
	// Matches https://cs.opensource.google/go/go/+/refs/tags/go1.23.6:src/text/template/exec.go;l=138
	traceableError, done = parseTemplateSimpleErrorString(remainder)
	if done {
		return traceableError, done
	}

	return TraceableError{}, false
}

// Special case: "template: no template %q associated with template %q"
// Matches https://cs.opensource.google/go/go/+/refs/tags/go1.23.6:src/text/template/exec.go;l=191
func parseTemplateNoTemplateError(s string, remainder string) (TraceableError, bool) {
	if strings.HasPrefix(remainder, "no template ") {
		return TraceableError{message: s}, true

Review comment (suggestion):
nitpick: it is an extra mental jump to infer that done must be true, so this is the equivalent:
```suggestion
		return traceableError, true
```

Code after:
	if t.location != "" {
		_, _ = fmt.Fprintf(&errorString, "%s\n  ", t.location)
	}
	if t.executedFunction != "" {
		_, _ = fmt.Fprintf(&errorString, "%s\n    ", t.executedFunction)
	}
	if t.message != "" {
		_, _ = fmt.Fprintf(&errorString, "%s\n", t.message)
	}
	return errorString.String()
}

// parseTemplateExecErrorString parses a template execution error string from text/template
// without using regular expressions. It returns a TraceableError and true if parsing succeeded.
func parseTemplateExecErrorString(s string) (TraceableError, bool) {
	const prefix = "template: "
	if !strings.HasPrefix(s, prefix) {
		return TraceableError{}, false
	}
	remainder := s[len(prefix):]

	// Special case: "template: no template %q associated with template %q"
	// Matches https://cs.opensource.google/go/go/+/refs/tags/go1.23.6:src/text/template/exec.go;l=191
	traceableError, done := parseTemplateNoTemplateError(s, remainder)
	if done {
		return traceableError, true
	}

	// Executing form: "<templateName>: executing \"<funcName>\" at <<location>>: <errMsg>[ template:...]"
	// Matches https://cs.opensource.google/go/go/+/refs/tags/go1.23.6:src/text/template/exec.go;l=141
	traceableError, done = parseTemplateExecutingAtErrorType(remainder)
	if done {
		return traceableError, true
	}

	// Simple form: "<templateName>: <errMsg>"
	// Use LastIndex to avoid splitting colons within line:col info.
	// Matches https://cs.opensource.google/go/go/+/refs/tags/go1.23.6:src/text/template/exec.go;l=138
	traceableError, done = parseTemplateSimpleErrorString(remainder)
	if done {
		return traceableError, true
	}

	return TraceableError{}, false
}

// Special case: "template: no template %q associated with template %q"
// Matches https://cs.opensource.google/go/go/+/refs/tags/go1.23.6:src/text/template/exec.go;l=191
func parseTemplateNoTemplateError(s string, remainder string) (TraceableError, bool) {
	if strings.HasPrefix(remainder, "no template ") {
		return TraceableError{message: s}, true