-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Description
Proposal Details
Hello all,
I would like to propose that the ExecError type found in text/template tracks more fields than just the name of the template and the error message which includes the template:
https://cs.opensource.google/go/go/+/refs/tags/go1.23.6:src/text/template/exec.go;l=114-147
I would like to propose that we introduce additional fields to include the location of the error (as in the line number and column number), a version of the error message string that does not include the template name, and the "context" (which means the executed function call). The proposed error type would look like the following:
type ExecError struct {
Name string // Name of template.
+ LineNumber int // line location of the template that triggered the error
+ ColumnNumber int // column number pointing to the template that triggered the error
+ Context string // the name of the function call that triggered the error
+ ErrWithoutTemplate string // Just the error message, no template / context info
Err error // Pre-formatted error.
}The reason that I am proposing these changes to the struct is because I am helping out with a downstream repository helm (https://github.com/helm/helm). I want to introduce a change to improve their error message formats.
issue in helm: helm/helm#13447
PR to helm: helm/helm#13586
In my PR to helm, I found that I needed to introduce string manipulation logic to extract these fields that are already captured, but not saved, inside the text/template error state.
Does this proposal make sense?
Thanks
Metadata
Metadata
Assignees
Labels
Type
Projects
Status