From 88cd4655ebf00a0c169545d05e24f38c0d216044 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Wed, 11 Nov 2015 18:13:57 +0900 Subject: [PATCH] Better error handling --- goldsmith.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/goldsmith.go b/goldsmith.go index 8c770d9..cac08a6 100644 --- a/goldsmith.go +++ b/goldsmith.go @@ -142,8 +142,6 @@ func (gs *goldsmith) cleanupFiles() { } func (gs *goldsmith) exportFile(file *File) { - defer file.Buff.Reset() - if file.Err != nil { return } @@ -250,19 +248,22 @@ func (gs *goldsmith) Chain(c Chainer, err error) Goldsmith { } func (gs *goldsmith) Complete() ([]*File, error) { - if gs.err != nil { - return nil, gs.err - } - s := gs.stages[len(gs.stages)-1] var files []*File for file := range s.output { - gs.exportFile(file) + if gs.err == nil { + gs.exportFile(file) + } + + file.Buff.Reset() files = append(files, file) } - gs.cleanupFiles() + if gs.err == nil { + gs.cleanupFiles() + } + return files, gs.err }