Merge pull request #20592 from erictune/fix-munge-2

Print line number of failed link conversion.
This commit is contained in:
Daniel Smith 2016-02-04 23:26:05 -08:00
commit 15df7c7251

View File

@ -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
}