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 {
|
2023-04-22 06:36:32 +03:00
|
|
|
w io.Writer
|
|
|
|
pr *output.Printing
|
2020-08-06 20:58:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewErrorWriter returns an output.ErrorWriter that
|
|
|
|
// outputs in text format.
|
2023-04-22 06:36:32 +03:00
|
|
|
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) {
|
2023-04-22 06:36:32 +03:00
|
|
|
fmt.Fprintln(w.w, w.pr.Error.Sprintf("sq: %v", err))
|
2020-08-06 20:58:47 +03:00
|
|
|
}
|