mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #20592 from erictune/fix-munge-2
Print line number of failed link conversion.
This commit is contained in:
commit
15df7c7251
@ -122,23 +122,25 @@ func processLink(in string, filePath string) (string, error) {
|
|||||||
// any relative links actually point to files that exist.
|
// any relative links actually point to files that exist.
|
||||||
func updateLinks(filePath string, mlines mungeLines) (mungeLines, error) {
|
func updateLinks(filePath string, mlines mungeLines) (mungeLines, error) {
|
||||||
var out mungeLines
|
var out mungeLines
|
||||||
errors := []string{}
|
allErrs := []string{}
|
||||||
|
|
||||||
for _, mline := range mlines {
|
for lineNum, mline := range mlines {
|
||||||
if mline.preformatted || !mline.link {
|
if mline.preformatted || !mline.link {
|
||||||
out = append(out, mline)
|
out = append(out, mline)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
line, err := processLink(mline.data, filePath)
|
line, err := processLink(mline.data, filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errors = append(errors, err.Error())
|
var s = fmt.Sprintf("On line %d: %s", lineNum, err.Error())
|
||||||
|
err := errors.New(s)
|
||||||
|
allErrs = append(allErrs, err.Error())
|
||||||
}
|
}
|
||||||
ml := newMungeLine(line)
|
ml := newMungeLine(line)
|
||||||
out = append(out, ml)
|
out = append(out, ml)
|
||||||
}
|
}
|
||||||
err := error(nil)
|
err := error(nil)
|
||||||
if len(errors) != 0 {
|
if len(allErrs) != 0 {
|
||||||
err = fmt.Errorf("%s", strings.Join(errors, "\n"))
|
err = fmt.Errorf("%s", strings.Join(allErrs, "\n"))
|
||||||
}
|
}
|
||||||
return out, err
|
return out, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user