<commit_before>/*
 * Copyright (c) 2012-2022 The ANTLR Project. All rights reserved.
 * Use of this file is governed by the BSD 3-clause license that
 * can be found in the LICENSE.txt file in the project root.
 */

package org.antlr.v4.test.runtime.states;

import org.antlr.v4.test.runtime.Stage;

public abstract class State {
	public final State previousState;

	public final Exception exception;

	public abstract Stage getStage();

	public boolean containsErrors() {
		return exception != null;
	}

	public String getErrorMessage() {
		String result = "State: " + getStage() + "; ";
		if (exception != null) {
			result += exception.toString();
		}
		return result;
	}

	public State(State previousState, Exception exception) {
		this.previousState = previousState;
		this.exception = exception;
	}
}<commit_msg>Augment error message during testing to include full cause of problem.<commit_after>/*
 * Copyright (c) 2012-2022 The ANTLR Project. All rights reserved.
 * Use of this file is governed by the BSD 3-clause license that
 * can be found in the LICENSE.txt file in the project root.
 */

package org.antlr.v4.test.runtime.states;

import org.antlr.v4.test.runtime.Stage;

public abstract class State {
	public final State previousState;

	public final Exception exception;

	public abstract Stage getStage();

	public boolean containsErrors() {
		return exception != null;
	}

	public String getErrorMessage() {
		String result = "State: " + getStage() + "; ";
		if (exception != null) {
			result += exception.toString();
			result += "\nCause:\n";
			result += exception.getCause().toString();
		}
		return result;
	}

	public State(State previousState, Exception exception) {
		this.previousState = previousState;
		this.exception = exception;
	}
}
{'fraction_non_alphanumeric': 0.10532276330690826, 'fraction_numerical': 0.01245753114382786, 'mean_word_length': 3.935754189944134, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5527570', 'n_tokens_mistral': 550, 'n_tokens_neox': 501, 'n_words': 178}