<commit_before>﻿using System;
using System.Collections;
using System.Reflection;
using System.Text.RegularExpressions;
using UnityEngine;

public class SimpleModComponentSolver : ComponentSolver
{
    public SimpleModComponentSolver(BombCommander bombCommander, BombComponent bombComponent, MethodInfo processMethod, MethodInfo forcedSolveMethod, Component commandComponent, FieldInfo zenmodefield) :
        base(bombCommander, bombComponent)
	{
		ProcessMethod = processMethod;
		ForcedSolveMethod = forcedSolveMethod;
        CommandComponent = commandComponent;
		ZenModeField = zenmodefield;
		ZenMode = OtherModes.ZenModeOn;
        modInfo = ComponentSolverFactory.GetModuleInfo(GetModuleType());
    }

	protected override IEnumerator RespondToCommandInternal(string inputCommand)
	{
		if (ProcessMethod == null)
		{
			DebugHelper.LogError("A declared TwitchPlays SimpleModComponentSolver process method is <null>, yet a component solver has been created; command invocation will not continue.");
			yield break;
		}

		KMSelectable[] selectableSequence = null;

		try
		{
			bool regexValid = modInfo.validCommands == null;
			if (!regexValid)
			{
				foreach (string regex in modInfo.validCommands)
				{
					regexValid = Regex.IsMatch(inputCommand, regex, RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
					if (regexValid)
						break;
				}
			}
			if (!regexValid)
				yield break;

			selectableSequence = (KMSelectable[]) ProcessMethod.Invoke(CommandComponent, new object[] { inputCommand });
			if (selectableSequence == null || selectableSequence.Length == 0)
				yield break;
		}
		catch (Exception ex)
		{
			DebugHelper.LogException(ex, string.Format("An exception occurred while trying to invoke {0}.{1}; the command invocation will not continue.", ProcessMethod.DeclaringType.FullName, ProcessMethod.Name));
			yield break;
		}

		yield return "modsequence";
		yield return selectableSequence;
	}
}
<commit_msg>Exceptions other than System.FormatException causes module to auto-solve<commit_after>﻿using System;
using System.Collections;
using System.Reflection;
using System.Text.RegularExpressions;
using UnityEngine;

public class SimpleModComponentSolver : ComponentSolver
{
    public SimpleModComponentSolver(BombCommander bombCommander, BombComponent bombComponent, MethodInfo processMethod, MethodInfo forcedSolveMethod, Component commandComponent, FieldInfo zenmodefield) :
        base(bombCommander, bombComponent)
	{
		ProcessMethod = processMethod;
		ForcedSolveMethod = forcedSolveMethod;
        CommandComponent = commandComponent;
		ZenModeField = zenmodefield;
		ZenMode = OtherModes.ZenModeOn;
        modInfo = ComponentSolverFactory.GetModuleInfo(GetModuleType());
    }

	protected override IEnumerator RespondToCommandInternal(string inputCommand)
	{
		if (ProcessMethod == null)
		{
			DebugHelper.LogError("A declared TwitchPlays SimpleModComponentSolver process method is <null>, yet a component solver has been created; command invocation will not continue.");
			yield break;
		}

		KMSelectable[] selectableSequence = null;

		string exception = null;
		try
		{
			bool regexValid = modInfo.validCommands == null;
			if (!regexValid)
			{
				foreach (string regex in modInfo.validCommands)
				{
					regexValid = Regex.IsMatch(inputCommand, regex, RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
					if (regexValid)
						break;
				}
			}
			if (!regexValid)
				yield break;

			selectableSequence = (KMSelectable[]) ProcessMethod.Invoke(CommandComponent, new object[] {inputCommand});
			if (selectableSequence == null || selectableSequence.Length == 0)
				yield break;
		}
		catch (FormatException ex)
		{
			DebugHelper.LogException(ex, string.Format("An exception occurred while trying to invoke {0}.{1}; the command invocation will not continue.", ProcessMethod.DeclaringType.FullName, ProcessMethod.Name));
			exception = ex.Message;
		}
		catch (Exception ex)
		{
			DebugHelper.LogException(ex, string.Format("An exception occurred while trying to invoke {0}.{1}; the command invocation will not continue.", ProcessMethod.DeclaringType.FullName, ProcessMethod.Name));
			throw;
		}

		if (exception != null)
		{
			yield return $"sendtochaterror {exception}";
			yield break;
		}

		yield return "modsequence";
		yield return selectableSequence;
	}
}

{'fraction_non_alphanumeric': 0.08523381709283576, 'fraction_numerical': 0.0018428933425478, 'mean_word_length': 4.690694626474443, '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': '1467917', 'n_tokens_mistral': 1369, 'n_tokens_neox': 1187, 'n_words': 318}