1
2
3
4
5
6 package org.openrdf.repository.augur.helpers;
7
8 import info.aduna.iteration.ExceptionConvertingIteration;
9 import info.aduna.iteration.Iteration;
10
11 import org.openrdf.query.QueryEvaluationException;
12 import org.openrdf.repository.RepositoryException;
13
14
15
16
17
18
19 public class RepositoryCloseableIteration<E> extends ExceptionConvertingIteration<E, RepositoryException> {
20
21
22
23
24 public RepositoryCloseableIteration(Iteration<? extends E, ? extends QueryEvaluationException> iter) {
25 super(iter);
26 }
27
28 @Override
29 protected RepositoryException convert(Exception e) {
30 if(e instanceof QueryEvaluationException) {
31 return new RepositoryException(e);
32 }
33 else if(e instanceof RuntimeException) {
34 throw (RuntimeException)e;
35 }
36 else if (e == null) {
37 throw new IllegalArgumentException("e must not be null");
38 }
39 else {
40 throw new IllegalArgumentException("Unexpected exception type: " + e.getClass());
41 }
42 }
43 }