cmd/lncli: [describegraph] -- if rendering fails, display error

This commit is contained in:
Olaoluwa Osuntokun 2017-01-25 18:29:24 -08:00
parent a5d2dbf219
commit 3aaf291409
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2

@ -918,18 +918,29 @@ func drawChannelGraph(graph *lnrpc.ChannelGraph) error {
return err
}
var errBuffer bytes.Buffer
// Once our dot file has been written to disk, we can use the dot
// command itself to generate the drawn rendering of the graph
// described.
drawCmd := exec.Command("dot", "-T"+"svg", "-o"+imageFile.Name(),
tempDotFile.Name())
drawCmd.Stderr = &errBuffer
if err := drawCmd.Run(); err != nil {
fmt.Println("error rendering graph: ", errBuffer.String())
fmt.Println("dot: ", graphDotString)
return err
}
errBuffer.Reset()
// Finally, we'll open the drawn graph to display to the user.
openCmd := exec.Command("open", imageFile.Name())
openCmd.Stderr = &errBuffer
if err := openCmd.Run(); err != nil {
fmt.Println("error opening rendered graph image: ",
errBuffer.String())
return err
}