<commit_before>package com.thoughtworks.xstream.converters;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

/**
 * Thrown by {@link Converter} implementations when they cannot convert an object
 * to/from textual data.
 *
 * @author <NAME>
 */
public class ConversionException extends RuntimeException implements ErrorWriter {

    private Map stuff = new HashMap();

    /**
     * Plays nice with JDK1.3 and JDK1.4
     */
    protected Exception cause;

    public ConversionException(String msg, Exception cause) {
        super(msg);
        if (cause != null) {
            add("exception", cause.getClass().getName());
            add("message", cause.getMessage());
            this.cause = cause;
        }
    }

    public ConversionException(String msg) {
        super(msg);
    }

    public ConversionException(Exception cause) {
        this(cause.getMessage(), cause);
    }

    public String get(String errorKey) {
        return (String) stuff.get(errorKey);
    }

    public void add(String name, String information) {
        stuff.put(name, information);
    }

    public Iterator keys() {
        return stuff.keySet().iterator();
    }

    public String getMessage() {<commit_msg>Added more to diagnostics.<commit_after>package com.thoughtworks.xstream.converters;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

/**
 * Thrown by {@link Converter} implementations when they cannot convert an object
 * to/from textual data.
 *
 * When this exception is thrown it can be passed around to things that accept an
 * {@link ErrorWriter}, allowing them to add diagnostics to the stack trace.
 *
 * @author <NAME>
 *
 * @see ErrorWriter
 */
public class ConversionException extends RuntimeException implements ErrorWriter {

    private Map stuff = new HashMap();

    /**
     * Plays nice with JDK1.3 and JDK1.4
     */
    protected Exception cause;

    public ConversionException(String msg, Exception cause) {
        super(msg);
        if (msg != null) {
            add("message", msg);
        }
        if (cause != null) {
            add("cause-exception", cause.getClass().getName());
            add("cause-message", cause.getMessage());
            this.cause = cause;
        }
    }

    public ConversionException(String msg) {
        super(msg);
    }

    public ConversionException(Exception cause) {
        this(cause.getMessage(), cause);
    }

    public String get(String errorKey) {
        return (String) stuff.get(errorKey);
    }

    public void add(String name, String information) {
        stuff.put(name, information);
    }

    public Iterator keys() {
        return stuff.keySet().iterator();
    }

    public String getMessage() {
{'fraction_non_alphanumeric': 0.10893246187363835, 'fraction_numerical': 0.002904865649963689, 'mean_word_length': 2.663563829787234, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4047616', 'n_tokens_mistral': 766, 'n_tokens_neox': 735, 'n_words': 222}