<commit_before>/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

package com.skelril.nitro.registry.dynamic;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;

public class LoaderRegistry {
    private Map<Loader, Path> loaders = new HashMap<>();

    public void registerLoader(Loader loader, Path path) {
        loaders.put(loader, path);
    }

    public void loadAll() {
        loaders.forEach((loader, path) -> {
            try {
                Files.walk(path).forEach(subPath -> {
                    if (subPath.getFileName().toString().endsWith(".json")) {
                        try {
                            loader.load(subPath);
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                });
            } catch (IOException e) {
                e.printStackTrace();
            }
        });
    }
}
<commit_msg>Added some extra error diagnostics information<commit_after>/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

package com.skelril.nitro.registry.dynamic;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;

public class LoaderRegistry {
    private Map<Loader, Path> loaders = new HashMap<>();

    public void registerLoader(Loader loader, Path path) {
        loaders.put(loader, path);
    }

    public void loadAll() {
        loaders.forEach((loader, path) -> {
            try {
                Files.walk(path).forEach(subPath -> {
                    String filename = subPath.getFileName().toString();
                    if (filename.endsWith(".json")) {
                        try {
                            loader.load(subPath);
                        } catch (Exception e) {
                            System.err.println("Error loading: " + filename);
                            e.printStackTrace();
                        }
                    }
                });
            } catch (IOException e) {
                e.printStackTrace();
            }
        });
    }
}

{'fraction_non_alphanumeric': 0.10996427153632393, 'fraction_numerical': 0.0031758634378721714, 'mean_word_length': 1.5740551583248212, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '4264899', 'n_tokens_mistral': 667, 'n_tokens_neox': 638, 'n_words': 177}