class ProblemService {

    @Transactional(readOnly = true)
    public Page<ErrorWithExecutedScenarioAndRunAndExecutionDTO> getProblemErrors(long projectId, long problemId, Pageable pageable) throws NotFoundException {
        Problem problem = problemRepository.findByProjectIdAndId(projectId, problemId);
        if (problem == null) {
            throw new NotFoundException(Messages.NOT_FOUND_PROBLEM, Entities.PROBLEM);
        }

        List<ProblemPattern> problemPatterns = problem.getPatterns();
        Page<Error> errors = errorRepository.findDistinctByProblemPatternsInOrderByExecutedScenarioRunExecutionTestDateTimeDesc(problemPatterns, pageable);
        if (errors == null) {
            return null;
        }
        return errors.map(errorWithExecutedScenarioAndRunAndExecutionMapper::toDto);
    }

}