@Override
    protected CompletableFuture<LogListInfo> handleRequest(
            @Nonnull HandlerRequest<EmptyRequestBody> request,
            @Nonnull ResourceManagerGateway gateway)
            throws RestHandlerException {
        final ResourceID taskManagerId = request.getPathParameter(TaskManagerIdPathParameter.class);
        final ResourceManagerGateway resourceManagerGateway =
                getResourceManagerGateway(resourceManagerGatewayRetriever);
        final CompletableFuture<Collection<LogInfo>> logsWithLengthFuture =
                resourceManagerGateway.requestTaskManagerLogList(taskManagerId, timeout);

        return logsWithLengthFuture
                .thenApply(LogListInfo::new)
                .exceptionally(
                        (throwable) -> {
                            final Throwable strippedThrowable =
                                    ExceptionUtils.stripCompletionException(throwable);
                            if (strippedThrowable instanceof UnknownTaskExecutorException) {
                                throw new CompletionException(
                                        new RestHandlerException(
                                                "Could not find TaskExecutor " + taskManagerId,
                                                HttpResponseStatus.NOT_FOUND,
                                                strippedThrowable));
                            } else {
                                throw new CompletionException(throwable);
                            }
                        });
    }
@Test
    void testGetTaskManagerLogsListForUnknownTaskExecutorException() throws Exception {
        resourceManagerGateway.setRequestTaskManagerLogListFunction(
                EXPECTED_TASK_MANAGER_ID ->
                        FutureUtils.completedExceptionally(
                                new UnknownTaskExecutorException(EXPECTED_TASK_MANAGER_ID)));
        try {
            taskManagerLogListHandler.handleRequest(handlerRequest, resourceManagerGateway).get();
        } catch (ExecutionException e) {
            final Throwable cause = e.getCause();
            assertThat(cause).isInstanceOf(RestHandlerException.class);

            final RestHandlerException restHandlerException = (RestHandlerException) cause;
            assertThat(restHandlerException.getHttpResponseStatus())
                    .isEqualTo(HttpResponseStatus.NOT_FOUND);
            assertThat(restHandlerException.getMessage())
                    .contains("Could not find TaskExecutor " + EXPECTED_TASK_MANAGER_ID);
        }
    }