<commit_before>﻿#region

using System;

#endregion

namespace Tabster.Core.FileTypes
{
    public class TabsterDocumentProcessor<T> where T : class, ITabsterDocument, new()
    {
        private readonly Version _latestVersion;
        private readonly bool _updateFormat;

        public TabsterDocumentProcessor(Version latestVersion, bool updateFormat)
        {
            _latestVersion = latestVersion;
            _updateFormat = updateFormat;
        }

        public Exception Error { get; private set; }

        public T Load(string fileName)
        {
            Error = null;

            var doc = new T();

            try
            {
                doc.Load(fileName);

                if (_latestVersion > doc.FileVersion && _updateFormat)
                {
                    doc.Update();
                }

                return doc;
            }

            catch (Exception ex)
            {
                Error = ex;
                return null;
            }
        }
    }
}<commit_msg>Added Load() overload with Exception out parameter.<commit_after>﻿#region

using System;

#endregion

namespace Tabster.Core.FileTypes
{
    public class TabsterDocumentProcessor<T> where T : class, ITabsterDocument, new()
    {
        private readonly Version _latestVersion;
        private readonly bool _updateFormat;

        public TabsterDocumentProcessor(Version latestVersion, bool updateFormat)
        {
            _latestVersion = latestVersion;
            _updateFormat = updateFormat;
        }

        public Exception Error { get; private set; }

        public T Load(string fileName)
        {
            Exception error;
            return Load(fileName, out error);
        }

        public T Load(string fileName, out Exception error)
        {
            Error = null;

            var doc = new T();

            try
            {
                doc.Load(fileName);

                if (_latestVersion > doc.FileVersion && _updateFormat)
                {
                    doc.Update();
                }

                error = null;
                return doc;
            }

            catch (Exception ex)
            {
                error = ex;
                Error = ex;
                return null;
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.06913043478260869, 'fraction_numerical': 0.0, 'mean_word_length': 1.3336713995943206, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '6629778', 'n_tokens_mistral': 562, 'n_tokens_neox': 532, 'n_words': 149}