packer/rpc: less panics

This commit is contained in:
Mitchell Hashimoto 2013-08-23 13:57:26 -07:00
parent 043264ca77
commit df70443a7c
1 changed files with 6 additions and 6 deletions

View File

@ -61,20 +61,20 @@ func (b *builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
go func() {
defer responseL.Close()
var response BuilderRunResponse
defer func() { runResponseCh <- &response }()
conn, err := responseL.Accept()
if err != nil {
log.Panic(err)
response.Err = err
return
}
defer conn.Close()
decoder := gob.NewDecoder(conn)
var response BuilderRunResponse
if err := decoder.Decode(&response); err != nil {
response.Err = fmt.Errorf("Error waiting for Run: %s", err)
}
runResponseCh <- &response
}()
args := &BuilderRunArgs{
@ -154,7 +154,7 @@ func (b *BuilderServer) Run(args *BuilderRunArgs, reply *interface{}) error {
err := responseWriter.Encode(&BuilderRunResponse{responseErr, responseAddress})
if err != nil {
panic(err)
log.Printf("BuildServer.Run error: %s", err)
}
}()