mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-13 03:56:39 +00:00
29 lines
555 B
Go
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
|
|
}
|
|
}
|