<commit_before>﻿using System;
using UniRx;

namespace Silphid.Sequencit
{
    public class Instant : IObservable<Unit>
    {
        private readonly Action _action;
        public static readonly IObservable<Unit> Default = new Instant();

        public Instant() {}

        public Instant(Action action)
        {
            _action = action;
        }

        public IDisposable Subscribe(IObserver<Unit> observer)
        {
            _action?.Invoke();
            observer.OnCompleted();
            return Disposable.Empty;
        }
    }
}<commit_msg>Added catch exception when invoking action of Instant.<commit_after>﻿using System;
using UniRx;

namespace Silphid.Sequencit
{
    public class Instant : IObservable<Unit>
    {
        private readonly Action _action;
        public static readonly IObservable<Unit> Default = new Instant();

        public Instant() {}

        public Instant(Action action)
        {
            _action = action;
        }

        public IDisposable Subscribe(IObserver<Unit> observer)
        {
            try
            {
                _action?.Invoke();
            }
            catch (Exception ex)
            {
                observer.OnError(ex);
                return Disposable.Empty;
            }
            
            observer.OnCompleted();
            return Disposable.Empty;
        }
    }
}
{'fraction_non_alphanumeric': 0.0794460641399417, 'fraction_numerical': 0.0, 'mean_word_length': 1.6557059961315281, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '1680450', 'n_tokens_mistral': 363, 'n_tokens_neox': 335, 'n_words': 86}