@@ -16,7 +16,7 @@ func EmptyHandler(Error) {}
1616// creates a basic handler that prints the formatted error on a line
1717func MakeBasicHandler (w io.Writer ) Handler {
1818 return func (err Error ) {
19- fmt .Fprintf (w , "%s: %s\n " , makeErrorHeader (err , "" ), err . Msg )
19+ fmt .Fprintf (w , "%s: %s\n " , makeErrorHeader (err , "" ), err )
2020 }
2121}
2222
@@ -36,13 +36,6 @@ func MakeAdvancedHandler(file string, src []byte, w io.Writer) Handler {
3636 return
3737 }
3838
39- // helper function to print s n-times
40- printN := func (n int , s string ) {
41- for i := 0 ; i < n ; i ++ {
42- fmt .Fprint (w , s )
43- }
44- }
45-
4639 // helper to find the maximum of two uints
4740 uMax := func (a , b uint ) uint {
4841 if a > b {
@@ -75,29 +68,29 @@ func MakeAdvancedHandler(file string, src []byte, w io.Writer) Handler {
7568
7669 if lineIndex == rnge .Start .Line - 1 {
7770 startLen := replaceAndCount (line [:rnge .Start .Column - 1 ])
78- printN (startLen , " " )
71+ printN (w , startLen , " " )
7972 restLen := replaceAndCount (line [rnge .Start .Column - 1 :])
8073 if rnge .Start .Line == rnge .End .Line {
8174 restLen = replaceAndCount (line [rnge .Start .Column - 1 : rnge .End .Column - 1 ])
8275 }
83- printN (restLen , "^" )
76+ printN (w , restLen , "^" )
8477 } else if lineIndex < rnge .End .Line - 1 {
85- printN (lineStart , " " )
86- printN (lineLen - lineStart , "^" )
78+ printN (w , lineStart , " " )
79+ printN (w , lineLen - lineStart , "^" )
8780 } else {
8881 restLen := replaceAndCount (line [:rnge .End .Column - 1 ])
8982 if lineStart < restLen {
90- printN (lineStart , " " )
91- printN (lineLen - lineStart , "^" )
83+ printN (w , lineStart , " " )
84+ printN (w , lineLen - lineStart , "^" )
9285 } else {
93- printN (restLen , "^" )
86+ printN (w , restLen , "^" )
9487 }
9588 }
9689 fmt .Fprint (w , "\n " )
9790 }
9891
99- fmt .Fprintf (w , "\n %s.\n \n " , err . Msg )
100- printN (maxLineCount , "-" )
92+ fmt .Fprintf (w , "\n %s.\n \n " , err )
93+ printN (w , maxLineCount , "-" )
10194 fmt .Fprint (w , "\n \n " )
10295 }
10396}
@@ -150,3 +143,10 @@ func (m *Collector) GetHandler() Handler {
150143 m .Errors = append (m .Errors , err )
151144 }
152145}
146+
147+ // helper function to print s n-times
148+ func printN (w io.Writer , n int , s string ) {
149+ for i := 0 ; i < n ; i ++ {
150+ fmt .Fprint (w , s )
151+ }
152+ }
0 commit comments