01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.repository.sail;
07:
08: import info.aduna.iteration.ExceptionConvertingIteration;
09: import info.aduna.iteration.Iteration;
10:
11: import org.openrdf.repository.RepositoryException;
12: import org.openrdf.sail.SailException;
13:
14: /**
15: * @author Herko ter Horst
16: */
17: class SailCloseableIteration<E> extends
18: ExceptionConvertingIteration<E, RepositoryException> {
19:
20: public SailCloseableIteration(
21: Iteration<? extends E, ? extends SailException> iter) {
22: super (iter);
23: }
24:
25: @Override
26: protected RepositoryException convert(Exception e) {
27: if (e instanceof SailException) {
28: return new RepositoryException(e);
29: } else if (e instanceof RuntimeException) {
30: throw (RuntimeException) e;
31: } else if (e == null) {
32: throw new IllegalArgumentException("e must not be null");
33: } else {
34: throw new IllegalArgumentException(
35: "Unexpected exception type: " + e.getClass());
36: }
37: }
38: }
|