class CommonHandler {

    CommonResponse newHttpResponseFromException(CommonRequest request,
            Authentication authentication, Exception exception) throws Exception {
        Exception e = exception;
        if (e instanceof InvocationTargetException) {
            Throwable cause = e.getCause();
            if (cause instanceof Exception) {
                e = (Exception) cause;
            }
        }
        if (e instanceof JsonServiceException) {
            // this is an "expected" exception, no need to log
            JsonServiceException jsonServiceException = (JsonServiceException) e;
            if (jsonServiceException.getStatus() == FORBIDDEN) {
                return handleNotAuthorized(request, authentication);
            } else {
                return newHttpResponseWithMessage(jsonServiceException.getStatus(),
                        jsonServiceException.getMessage());
            }
        }
        logger.error(e.getMessage(), e);
        if (e instanceof SQLException
                && ((SQLException) e).getErrorCode() == H2_STATEMENT_WAS_CANCELED) {
            return newHttpResponseWithMessage(REQUEST_TIMEOUT,
                    "Query timed out (timeout is configurable under Configuration > Advanced)");
        }
        return newHttpResponseWithStackTrace(e, INTERNAL_SERVER_ERROR, null);
    }

      CommonHandler(boolean central, LayoutService layoutService,
            Map<Pattern, HttpService> httpServices, HttpSessionManager httpSessionManager,
            List<Object> jsonServices, Clock clock);

}