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