<commit_before>﻿using System.Runtime.Remoting.Contexts;
using Android.Widget;
using Android.App;

namespace Figlut.MonoDroid.Toolkit.Utilities
{
    #region Using Directives

    using System;
    using System.Collections.Generic;
    using System.Text;
    using Figlut.MonoDroid.Toolkit.Utilities.Logging;

    #endregion //Using Directives

    /// <summary>
    /// A helper class for handling exceptions i.e. logging and displaying them.
    /// </summary>
    public class ExceptionHandler
    {
        #region Methods

        /// <summary>
        /// Handles an exption by logging and/or displaying it.
        /// Also temporarily disables the specified form's key up event handler.
        /// </summary>
        /// <param name="exception">The exception to handle.</param>
        /// <param name="log">Whether or not to use the Logger to log the exception to a log file.</param>
        /// <param name="display">Whether or not to display the exception mesage and its inner exception message if one exists.</param>
		public static bool HandleException(Exception exception, Activity activity)
        {
            try
            {
                bool closeApplication = false;
                if (exception == null)
                {
                    throw new NullReferenceException("exception to be handled may not be null.");
                }
                if (GOC.Instance.ShowMessageBoxOnException)
                {
					Toast.MakeText(activity, exception.Message, ToastLength.Long).Show();
                }
                UserThrownException userThrownException = exception as UserThrownException;
                if (userThrownException != null)
                {
                    closeApplication = userThrownException.CloseApplication;
                    GOC.Instance.Logger.LogMessage(new LogError(exception, userThrownException.LoggingLevel));
                }
                else
                {
                    GOC.Instance.Logger.LogMessage(new LogError(exception, LoggingLevel.Normal));
                }
                if (closeApplication)
                {
					activity.Finish();<commit_msg>Added HandleException method that allows you to not specify an activity, in which case it will not show a toast.<commit_after>﻿using System.Runtime.Remoting.Contexts;
using Android.Widget;
using Android.App;

namespace Figlut.MonoDroid.Toolkit.Utilities
{
    #region Using Directives

    using System;
    using System.Collections.Generic;
    using System.Text;
    using Figlut.MonoDroid.Toolkit.Utilities.Logging;

    #endregion //Using Directives

    /// <summary>
    /// A helper class for handling exceptions i.e. logging and displaying them.
    /// </summary>
    public class ExceptionHandler
    {
        #region Methods

        /// <summary>
        /// Handles an exption by logging it.
        /// </summary>
        /// <param name="exception">The exception to handle.</param>
        public static bool HandleException(Exception exception)
        {
            return HandleException(exception, null);
        }

        /// <summary>
        /// Handles an exption by logging and/or displaying it (if an actvity is specified.
        /// </summary>
        /// <param name="exception">The exception to handle.</param>
        /// <param name="activity">If an activity is specified, a Toast will be shown with the exception's message.</param>
		public static bool HandleException(Exception exception, Activity activity)
        {
            try
            {
                bool closeApplication = false;
                if (exception == null)
                {
                    throw new NullReferenceException("exception to be handled may not be null.");
                }
                if (GOC.Instance.ShowMessageBoxOnException && (activity != null))
                {
					Toast.MakeText(activity, exception.Message, ToastLength.Long).Show();
                }
                UserThrownException userThrownException = exception as UserThrownException;
                if (userThrownException != null)
                {
                    closeApplication = userThrownException.CloseApplication;
                    GOC.Instance.Logger.LogMessage(new LogError(exception, userThrownException.LoggingLevel));
                }
                else
                {
                    GOC.Instance.Logger.LogMessage(new LogError(exception, LoggingLevel.Normal));
                }
                if (closeApplication && (activity != null))
                {
					activity.Finish();
{'fraction_non_alphanumeric': 0.08784227820372399, 'fraction_numerical': 0.0, 'mean_word_length': 1.8880455407969639, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '4942945', 'n_tokens_mistral': 1129, 'n_tokens_neox': 1051, 'n_words': 314}