sq/cli/output/tablew/errorwriter.go
2020-08-06 11:58:47 -06:00

26 lines
519 B
Go

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