Better error handling

This commit is contained in:
Alex Yatskov 2015-11-11 18:13:57 +09:00
parent eee9607a81
commit 88cd4655eb

View File

@ -142,8 +142,6 @@ func (gs *goldsmith) cleanupFiles() {
} }
func (gs *goldsmith) exportFile(file *File) { func (gs *goldsmith) exportFile(file *File) {
defer file.Buff.Reset()
if file.Err != nil { if file.Err != nil {
return return
} }
@ -250,19 +248,22 @@ func (gs *goldsmith) Chain(c Chainer, err error) Goldsmith {
} }
func (gs *goldsmith) Complete() ([]*File, error) { func (gs *goldsmith) Complete() ([]*File, error) {
if gs.err != nil {
return nil, gs.err
}
s := gs.stages[len(gs.stages)-1] s := gs.stages[len(gs.stages)-1]
var files []*File var files []*File
for file := range s.output { for file := range s.output {
gs.exportFile(file) if gs.err == nil {
gs.exportFile(file)
}
file.Buff.Reset()
files = append(files, file) files = append(files, file)
} }
gs.cleanupFiles() if gs.err == nil {
gs.cleanupFiles()
}
return files, gs.err return files, gs.err
} }