main: check for error after starting the OCD daemon

This replaces a panic with an informative error message if the right
tool (such as OpenOCD) is not installed.
Этот коммит содержится в:
Ayke van Laethem 2020-02-24 15:05:48 +01:00 коммит произвёл Daniel Esteban
родитель e83d1a02b6
коммит b3d3debd4c

15
main.go
Просмотреть файл

@ -335,7 +335,10 @@ func FlashGDB(pkgName string, ocdOutput bool, options *compileopts.Options) erro
// GDB (to break the currently executing program).
setCommandAsDaemon(daemon)
// Start now, and kill it on exit.
daemon.Start()
err = daemon.Start()
if err != nil {
return &commandError{"failed to run", daemon.Path, err}
}
defer func() {
daemon.Process.Signal(os.Interrupt)
// Maybe we should send a .Kill() after x seconds?
@ -360,7 +363,10 @@ func FlashGDB(pkgName string, ocdOutput bool, options *compileopts.Options) erro
// GDB (to break the currently executing program).
setCommandAsDaemon(daemon)
// Start now, and kill it on exit.
daemon.Start()
err = daemon.Start()
if err != nil {
return &commandError{"failed to run", daemon.Path, err}
}
defer func() {
daemon.Process.Signal(os.Interrupt)
// Maybe we should send a .Kill() after x seconds?
@ -380,7 +386,10 @@ func FlashGDB(pkgName string, ocdOutput bool, options *compileopts.Options) erro
setCommandAsDaemon(daemon)
// Start now, and kill it on exit.
daemon.Start()
err = daemon.Start()
if err != nil {
return &commandError{"failed to run", daemon.Path, err}
}
defer func() {
daemon.Process.Signal(os.Interrupt)
// Maybe we should send a .Kill() after x seconds?