Permalink
Browse files

updated exception handling

  • Loading branch information...
1 parent 17271fe commit 71669ae3c0f22cd7adf46619f49d366508872f2a @ghosthack ghosthack committed Jan 26, 2012
View
18 embedded-api/com/flaptor/indextank/api/IndexEngineApi.java
@@ -69,7 +69,7 @@ public SearchResults search(String queryStr,
List<CategoryFilter> facetsFilter,
List<RangeFilter> variableRangeFilters,
List<RangeFilter> functionRangeFilters,
- Map<String,String> extraParameters) throws IndextankException, InvalidQueryException, MissingQueryVariableException {
+ Map<String,String> extraParameters) throws IndexEngineApiException {
DocumentSearcher searcher = engine.getSearcher();
try {
Query query = generateQuery(queryStr, start, len,
@@ -83,19 +83,13 @@ public SearchResults search(String queryStr,
SearchResults search = searcher.search(query, start, len, scoringFunctionIndex, extraParameters);
return search;
} catch (NoSuchQueryVariableException e) {
- MissingQueryVariableException ite = new MissingQueryVariableException();
- ite.set_message("Missing query variable with index '" + e.getMissingVariableIndex() + "'");
- throw ite;
- } catch (ParseException pe) {
- InvalidQueryException ite = new InvalidQueryException();
- ite.set_message("Invalid query");
- throw ite;
+ throw new IndexEngineApiException("Missing query variable with index '" + e.getMissingVariableIndex() + "'", e);
+ } catch (ParseException e) {
+ throw new IndexEngineApiException("Invalid query", e);
} catch (RuntimeException e) {
- throw new IndextankException();
+ throw new IndexEngineApiException(e);
} catch (InterruptedException e) {
- IndextankException ite = new IndextankException();
- ite.set_message("Interrupted while searching.");
- throw ite;
+ throw new IndexEngineApiException("Interrupted while searching.", e);
}
}
View
19 embedded-api/com/flaptor/indextank/api/IndexEngineApiException.java
@@ -0,0 +1,19 @@
+package com.flaptor.indextank.api;
+
+public class IndexEngineApiException extends Exception {
+
+ public IndexEngineApiException(String message) {
+ super(message);
+ }
+
+ public IndexEngineApiException(Throwable cause) {
+ super(cause);
+ }
+
+ public IndexEngineApiException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ private static final long serialVersionUID = 1L;
+
+}
View
13 embedded-api/com/flaptor/indextank/api/resources/Search.java
@@ -28,11 +28,9 @@
import org.json.simple.JSONObject;
import com.flaptor.indextank.api.IndexEngineApi;
+import com.flaptor.indextank.api.IndexEngineApiException;
import com.flaptor.indextank.api.util.QueryHelper;
import com.flaptor.indextank.rpc.CategoryFilter;
-import com.flaptor.indextank.rpc.IndextankException;
-import com.flaptor.indextank.rpc.InvalidQueryException;
-import com.flaptor.indextank.rpc.MissingQueryVariableException;
import com.flaptor.indextank.rpc.RangeFilter;
import com.flaptor.indextank.search.SearchResult;
import com.flaptor.indextank.search.SearchResults;
@@ -92,14 +90,7 @@ public void run() {
print(jo.toJSONString());
return;
- } catch (IndextankException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (InvalidQueryException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (MissingQueryVariableException e) {
- // TODO Auto-generated catch block
+ } catch (IndexEngineApiException e) {
e.printStackTrace();
}

0 comments on commit 71669ae

Please sign in to comment.