mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-14 19:27:58 +08:00
Add a catch-all ErrInterrupted raiser.
This commit is contained in:
parent
d69530f8b4
commit
d7dd1fa85d
10
eval/eval.go
10
eval/eval.go
|
@ -264,6 +264,16 @@ func catch(perr *error, ec *EvalCtx) {
|
|||
// function.
|
||||
r := recover()
|
||||
if r == nil {
|
||||
// Ideally, all evaluation methods should keep an eye on ec.intCh and
|
||||
// raise ErrInterrupted as soon as possible. However, this is quite
|
||||
// tedious and only evaluation methods that may take an indefinite
|
||||
// amount of time do this. The code below ensures that ErrInterrupted
|
||||
// is always raised when there is an interrupt.
|
||||
select {
|
||||
case <-ec.intCh:
|
||||
*perr = &util.PosError{ec.begin, ec.end, ErrInterrupted}
|
||||
default:
|
||||
}
|
||||
return
|
||||
}
|
||||
if exc, ok := r.(util.Exception); ok {
|
||||
|
|
Loading…
Reference in New Issue
Block a user