Skip to content
This repository has been archived by the owner on May 4, 2023. It is now read-only.

Commit

Permalink
gracefully report errors while searching.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Newson committed Mar 7, 2009
1 parent fd16315 commit 8116d82
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/apache/couchdb/lucene/Index.java
Expand Up @@ -257,7 +257,7 @@ private void add(final Document out, final String key, final Object value, final
*
* type can be created, updated or deleted.
*/
public static void main(final String[] args) throws Exception {
public static void main(final String[] args) {
final Runnable indexer = new Indexer();
final Thread indexerThread = new Thread(indexer, "indexer");
indexerThread.setDaemon(true);
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/org/apache/couchdb/lucene/Search.java
Expand Up @@ -2,6 +2,7 @@

import java.util.Scanner;

import org.apache.commons.lang.StringEscapeUtils;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.store.NIOFSDirectory;
Expand Down Expand Up @@ -41,8 +42,12 @@ public static void main(final String[] args) throws Exception {
System.out.println("{\"code\":503,\"body\":\"couchdb-lucene not available.\"}");
} else {
final SearchRequest request = new SearchRequest(line);
final String result = request.execute(searcher);
System.out.println(result);
try {
final String result = request.execute(searcher);
System.out.println(result);
} catch (final Exception e) {
System.out.printf("{\"code\":400,\"body\":\"%s\"}\n", StringEscapeUtils.escapeHtml(e.getMessage()));
}
}
}
if (reader != null) {
Expand Down

0 comments on commit 8116d82

Please sign in to comment.