Add a catch-all ErrInterrupted raiser.

This commit is contained in:
Qi Xiao 2016-06-28 23:22:30 +02:00
parent d69530f8b4
commit d7dd1fa85d

View File

@ -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 {