From 957afa6db6be8b76967afba284ebfdd82b50f3eb Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Tue, 4 Feb 2014 16:37:58 +0900 Subject: [PATCH] Internal server error when running apropos command without doc index If the apropos command is run on a server where the documentation index is not available, it returns an internal server error. Add handling of document query errors and return a meaningful error message. Change-Id: Ic8fdbc504f0666ddb298c66f0e24ea13250977e6 --- .../google/gerrit/sshd/commands/AproposCommand.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/AproposCommand.java b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/AproposCommand.java index 813f1320f1..a27027ccb2 100644 --- a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/AproposCommand.java +++ b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/AproposCommand.java @@ -16,6 +16,7 @@ package com.google.gerrit.sshd.commands; import com.google.gerrit.server.config.CanonicalWebUrl; import com.google.gerrit.server.documentation.QueryDocumentationExecutor; +import com.google.gerrit.server.documentation.QueryDocumentationExecutor.DocQueryException; import com.google.gerrit.server.documentation.QueryDocumentationExecutor.DocResult; import com.google.gerrit.sshd.CommandMetaData; import com.google.gerrit.sshd.SshCommand; @@ -37,10 +38,14 @@ final class AproposCommand extends SshCommand { @Override public void run() throws Exception { - List res = searcher.doQuery(q); - for (DocResult docResult : res) { - stdout.println(String.format("%s:\n%s%s\n", docResult.title, url, - docResult.url)); + try { + List res = searcher.doQuery(q); + for (DocResult docResult : res) { + stdout.println(String.format("%s:\n%s%s\n", docResult.title, url, + docResult.url)); + } + } catch (DocQueryException dqe) { + throw new UnloggedFailure(1, "fatal: " + dqe.getMessage()); } } }