From cf4ad07adc65ac5224d8d44d1982f858de3d1eb8 Mon Sep 17 00:00:00 2001 From: Eric Tune Date: Mon, 11 Jan 2016 12:05:20 -0800 Subject: [PATCH] Print line number of failed link conversion. --- cmd/mungedocs/links.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cmd/mungedocs/links.go b/cmd/mungedocs/links.go index 9fb82ac16a7..af1b9ecdfb2 100644 --- a/cmd/mungedocs/links.go +++ b/cmd/mungedocs/links.go @@ -122,23 +122,25 @@ func processLink(in string, filePath string) (string, error) { // any relative links actually point to files that exist. func updateLinks(filePath string, mlines mungeLines) (mungeLines, error) { var out mungeLines - errors := []string{} + allErrs := []string{} - for _, mline := range mlines { + for lineNum, mline := range mlines { if mline.preformatted || !mline.link { out = append(out, mline) continue } line, err := processLink(mline.data, filePath) 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) out = append(out, ml) } err := error(nil) - if len(errors) != 0 { - err = fmt.Errorf("%s", strings.Join(errors, "\n")) + if len(allErrs) != 0 { + err = fmt.Errorf("%s", strings.Join(allErrs, "\n")) } return out, err }