From 1486d4db0a60a94cecda416934d8fb1f14d8bf1a Mon Sep 17 00:00:00 2001 From: Yota Toyama Date: Sat, 18 Nov 2017 16:07:58 +0900 Subject: [PATCH] Fix error messages about non-existent files --- examples/error.feature | 1 + file_result.go | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/examples/error.feature b/examples/error.feature index 1aa5bd5..efadd9d 100644 --- a/examples/error.feature +++ b/examples/error.feature @@ -8,3 +8,4 @@ Feature: Error Given a file named "foo.md" with "" When I run `linkcheck bar.md` Then the exit status should be 1 + And the stderr should contain "no such file" diff --git a/file_result.go b/file_result.go index 813fa91..2c345c1 100644 --- a/file_result.go +++ b/file_result.go @@ -1,6 +1,10 @@ package main -import "strings" +import ( + "strings" + + "github.com/fatih/color" +) type fileResult struct { filename string @@ -11,6 +15,10 @@ type fileResult struct { func (r fileResult) String(verbose bool) string { ss := make([]string, 0, len(r.urlResults)) + if r.err != nil { + ss = append(ss, "\t"+color.RedString(r.err.Error())) + } + for _, r := range r.urlResults { if r.err != nil || verbose { ss = append(ss, "\t"+r.String())