Exemple #1
0
//ReportError instantiates a command result with the contents of the ErrorMessageView as the message for the error,
// sends the error on the channel and deletes the views on error reporting. Deletes the action from the window too
func (c *CUI) ReportError(g *gocui.Gui, v *gocui.View) error {
	res := *NewCUICommandResult(c.cmdList[c.selectedCommand].Id, errors.New(v.Buffer())) //TODO strip \n ??
	c.CmdOut <- res
	err := c.cmdDone(c.selectedCommand)
	if err != nil {
		return err
	}
	//find all the views and exit
	if err := c.G.DeleteView("ErrorMessageTittleView"); err != nil {
		return err
	}
	if err := c.G.DeleteView("ErrorMessageView"); err != nil {
		return err
	}
	return c.deleteView(g, v)
}