sq/cli/output/tablew/errorwriter.go

26 lines
519 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
f *output.Formatting
}
// NewErrorWriter returns an output.ErrorWriter that
// outputs in text format.
func NewErrorWriter(w io.Writer, f *output.Formatting) output.ErrorWriter {
return &errorWriter{w: w, f: f}
}
// Error implements output.ErrorWriter.
func (w *errorWriter) Error(err error) {
fmt.Fprintln(w.w, w.f.Error.Sprintf("sq: %v", err))
}