diff options
Diffstat (limited to 'src/library/scala/xml/pull')
-rwxr-xr-x | src/library/scala/xml/pull/XMLEventReader.scala | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/library/scala/xml/pull/XMLEventReader.scala b/src/library/scala/xml/pull/XMLEventReader.scala index 428c305055..26572c9946 100755 --- a/src/library/scala/xml/pull/XMLEventReader.scala +++ b/src/library/scala/xml/pull/XMLEventReader.scala @@ -91,12 +91,16 @@ extends scala.collection.AbstractIterator[XMLEvent] override def run() { curInput = input - interruptibly { this.initialize.document() } - setEvent(POISON) + try interruptibly { this.initialize.document() } + catch { case e:Exception => setEvent(ExceptionEvent(e)) } + finally setEvent(POISON) } } } +// An internal class used to propagate exception from helper threads to API end users. +private case class ExceptionEvent(exception:Exception) extends XMLEvent + // An iterator designed for one or more producers to generate // elements, and a single consumer to iterate. Iteration will continue // until closeIterator() is called, after which point producers @@ -141,6 +145,7 @@ trait ProducerConsumerIterator[T >: Null] extends Iterator[T] { def next() = { if (eos) throw new NoSuchElementException("ProducerConsumerIterator") if (buffer == null) fillBuffer + if (buffer.isInstanceOf[ExceptionEvent]) throw buffer.asInstanceOf[ExceptionEvent].exception drainBuffer } |