Browse files

marshal errors for missing sections better.

  • Loading branch information...
1 parent 6330a04 commit 094ac8c63733beed996f41e692b7afc5b0b29f27 Robert Newson committed Jun 6, 2011
Showing with 7 additions and 5 deletions.
  1. +7 −5 src/main/java/com/github/rnewson/couchdb/lucene/LuceneServlet.java
View
12 src/main/java/com/github/rnewson/couchdb/lucene/LuceneServlet.java
@@ -17,6 +17,7 @@
*/
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
@@ -126,11 +127,12 @@ private void cleanup(final HttpServletRequest req,
}
private Couch getCouch(final HttpServletRequest req) throws IOException {
- final Configuration section = ini.getSection(new PathParts(req)
- .getKey());
- final String url = section.containsKey("url") ? section
- .getString("url") : null;
- return new Couch(client, url);
+ final String sectionName = new PathParts(req).getKey();
+ final Configuration section = ini.getSection(sectionName);
+ if (!section.containsKey("url")) {
+ throw new FileNotFoundException(sectionName + " is missing or has no url parameter.");
+ }
+ return new Couch(client, section.getString("url"));
}
private synchronized DatabaseIndexer getIndexer(final Database database)

0 comments on commit 094ac8c

Please sign in to comment.