Skip to content

Commit 38625bb

Browse files
author
Vladimir Kotal
committed
more verbose error for index problems
1 parent 876391f commit 38625bb

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/web/SearchHelper.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
2222
* Portions Copyright (c) 2011, Jens Elkner.
2323
* Portions Copyright (c) 2017, 2020, Chris Fraire <[email protected]>.
2424
*/
@@ -314,12 +314,14 @@ public SearchHelper prepareExec(SortedSet<String> projects) {
314314
// We use MultiReader even for single project. This should
315315
// not matter given that MultiReader is just a cheap wrapper
316316
// around set of IndexReader objects.
317-
reader = RuntimeEnvironment.getInstance().getMultiReader(
318-
projects, searcherList);
317+
reader = RuntimeEnvironment.getInstance().getMultiReader(projects, searcherList);
319318
if (reader != null) {
320319
searcher = new IndexSearcher(reader);
321320
} else {
322-
errorMsg = "Failed to initialize search. Check the index.";
321+
errorMsg = "Failed to initialize search. Check the index";
322+
if (projects.size() > 0) {
323+
errorMsg = errorMsg + " for projects: " + String.join(", ", projects);
324+
}
323325
return this;
324326
}
325327
}
@@ -344,8 +346,11 @@ public SearchHelper prepareExec(SortedSet<String> projects) {
344346
} catch (ParseException e) {
345347
errorMsg = PARSE_ERROR_MSG + e.getMessage();
346348
} catch (FileNotFoundException e) {
347-
// errorMsg = "Index database(s) not found: " + e.getMessage();
348-
errorMsg = "Index database(s) not found.";
349+
errorMsg = "Index database not found";
350+
if (projects.size() > 0) {
351+
errorMsg = errorMsg + " for projects: " + String.join(", ", projects);
352+
}
353+
errorMsg = errorMsg + " " + e.getMessage();
349354
} catch (IOException e) {
350355
errorMsg = e.getMessage();
351356
}

0 commit comments

Comments
 (0)