Remove StorageException catch clauses from httpd

Some of these are the antipattern of returning an empty result instead
of letting a fatal error propagate. In others, the purpose of the catch
clause is to do additional logging or add context information to the
exception message. In these cases, switch to catching RuntimeException
instead, under the assumption that the additional context is useful
regardless of the type of unexpected error.

Change-Id: I21b94ae2c00b9c09c2b81c5fc8cd1b66bb491bc9
This commit is contained in:
Dave Borowitz
2019-01-15 19:34:26 -08:00
parent 4737b47546
commit 40814dd46d
7 changed files with 17 additions and 37 deletions

View File

@@ -19,7 +19,6 @@ import static javax.servlet.http.HttpServletResponse.SC_FORBIDDEN;
import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
import com.google.common.flogger.FluentLogger;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.registration.DynamicItem;
import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
@@ -110,7 +109,7 @@ class RunAsFilter implements Filter {
} catch (UnprocessableEntityException e) {
replyError(req, res, SC_FORBIDDEN, "no account matches " + RUN_AS, null);
return;
} catch (StorageException | IOException | ConfigInvalidException e) {
} catch (IOException | ConfigInvalidException | RuntimeException e) {
logger.atWarning().withCause(e).log("cannot resolve account for %s", RUN_AS);
replyError(req, res, SC_INTERNAL_SERVER_ERROR, "cannot resolve " + RUN_AS, e);
return;