-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror.go
41 lines (33 loc) · 992 Bytes
/
error.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package surveyexpect
import (
"errors"
"github.com/AlecAivazis/survey/v2/terminal"
)
var (
// ErrNothingToDo indicates that there is nothing to do.
ErrNothingToDo = errors.New("nothing to do")
// ErrNotFinished indicates that the step is not finished.
ErrNotFinished = errors.New("step is not finished")
// ErrSequenceClosed indicates that the step is closed and does not take more action.
ErrSequenceClosed = errors.New("sequence is closed")
)
// IsIgnoredError checks whether the error is ignored.
func IsIgnoredError(err error) bool {
if err == nil {
return true
}
return IsInterrupted(err)
}
// IsInterrupted checks if the error is terminal.InterruptErr or not.
func IsInterrupted(err error) bool {
return errors.Is(err, terminal.InterruptErr)
}
// IsNothingTodo checks if the error is ErrNothingToDo or not.
func IsNothingTodo(err error) bool {
return errors.Is(err, ErrNothingToDo)
}
func mustNotClosed(closed bool) {
if closed {
panic(ErrSequenceClosed)
}
}