harness-drone/engine/runner/parse/node_recover.go
2016-04-16 00:51:05 -07:00

29 lines
555 B
Go

package parse
import "fmt"
type RecoverNode struct {
NodeType `json:"type"`
Body Node `json:"body"` // evaluate node and catch all errors.
}
func NewRecoverNode() *RecoverNode {
return &RecoverNode{NodeType: NodeRecover}
}
func (n *RecoverNode) SetBody(node Node) *RecoverNode {
n.Body = node
return n
}
func (n *RecoverNode) Validate() error {
switch {
case n.NodeType != NodeRecover:
return fmt.Errorf("Recover Node uses an invalid type")
case n.Body == nil:
return fmt.Errorf("Recover Node body is empty")
default:
return nil
}
}