summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--manager.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/manager.go b/manager.go
index 470fbf3..ea1d15a 100644
--- a/manager.go
+++ b/manager.go
@@ -46,6 +46,10 @@ type Work struct {
err error
}
+func (w *Work) Error() error {
+ return w.err
+}
+
func (i *StdinInput) Start() chan *Work {
i.retchan = make(chan *Work, 100)
r := bufio.NewReader(os.Stdin)
@@ -68,6 +72,10 @@ func (i *StdinInput) Start() chan *Work {
return i.retchan
}
+func NewStringFilter(ffmap map[string]func(string) string) *StringFilter {
+ return &StringFilter{FilterFuncMap: ffmap}
+}
+
func (f *StringFilter) Filter(w *Work) *Work {
dec := json.NewDecoder(bytes.NewReader(w.data))
jm := make(map[string]string, 10)
@@ -119,6 +127,10 @@ func (m *Manager) Run() {
go func(w *Work) {
nw := m.Filter.Filter(w)
+ err := nw.Error()
+ if err != nil {
+ fmt.Printf("Got an error when processing Work: %q\n", err)
+ }
m.Output.Output(nw)
wg.Done()
@@ -134,7 +146,7 @@ func main() {
m := Manager{
Input: &StdinInput{},
- Filter: &StringFilter{FilterFuncMap: ffmap},
+ Filter: NewStringFilter(ffmap),
Output: &StdoutOutput{},
}