<commit_before>package com.google.sitebricks.validation;

import java.util.List;
import java.util.Set;

import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
import javax.validation.ValidationException;

import com.google.common.collect.Lists;

public class ValidationUtil {
    
    public static List<String> toErrors(ValidationException ve) {
        ConstraintViolationException cve = (ConstraintViolationException) ve.getCause();
        return toErrors((Set<? extends ConstraintViolation<?>>) cve.getConstraintViolations());
    }
    
    public static List<String> toErrors(Set<? extends ConstraintViolation<?>> cvs) {
        List<String> errors = Lists.newArrayList();
        for (ConstraintViolation<?> cv: cvs) {
            errors.add(cv.getMessage());
        }
        return errors;
    }
    
}
<commit_msg>add guard against npe when creating the errors<commit_after>package com.google.sitebricks.validation;

import java.util.List;
import java.util.Set;

import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
import javax.validation.ValidationException;

import com.google.common.collect.Lists;

public class ValidationUtil {
    
    public static List<String> toErrors(ValidationException ve) {
        ConstraintViolationException cve = (ConstraintViolationException) ve.getCause();
        return toErrors((Set<? extends ConstraintViolation<?>>) cve.getConstraintViolations());
    }
    
    public static List<String> toErrors(Set<? extends ConstraintViolation<?>> cvs) {
        List<String> errors = Lists.newArrayList();
        if (cvs != null) {
            for (ConstraintViolation<?> cv: cvs) {
                errors.add(cv.getMessage());
            }
        }
        return errors;
    }
    
}

{'fraction_non_alphanumeric': 0.10318331503841932, 'fraction_numerical': 0.0, 'mean_word_length': 3.6505102040816326, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1118934', 'n_tokens_mistral': 495, 'n_tokens_neox': 505, 'n_words': 106}