sq/cli/output/tablew/errorwriter.go

26 lines
521 B
Go
Raw Normal View History

2020-08-06 20:58:47 +03:00
package tablew
import (
"fmt"
"io"
"github.com/neilotoole/sq/cli/output"
)
// errorWriter implements output.ErrorWriter.
type errorWriter struct {
w io.Writer
pr *output.Printing
2020-08-06 20:58:47 +03:00
}
// NewErrorWriter returns an output.ErrorWriter that
// outputs in text format.
func NewErrorWriter(w io.Writer, pr *output.Printing) output.ErrorWriter {
return &errorWriter{w: w, pr: pr}
2020-08-06 20:58:47 +03:00
}
// Error implements output.ErrorWriter.
func (w *errorWriter) Error(err error) {
fmt.Fprintln(w.w, w.pr.Error.Sprintf("sq: %v", err))
2020-08-06 20:58:47 +03:00
}