<commit_before>﻿namespace phoenix
{
    using System;
    using System.IO;
    using System.Drawing;
    using System.Windows.Forms;
    using System.Drawing.Imaging;

    class ScreenCapture
    {
        public static string ScreenShotDirectory
        {
            get { return "captures"; }
        }

        public static string TakeScreenShot(string image_path = "")
        {
            string path = string.Empty;

            using (Bitmap bmp = new Bitmap(
                Screen.PrimaryScreen.Bounds.Width,
                Screen.PrimaryScreen.Bounds.Height))
            {
                using (Graphics graphics = Graphics.FromImage(bmp))
                {
                    graphics.CopyFromScreen(
                        Screen.PrimaryScreen.Bounds.X,
                        Screen.PrimaryScreen.Bounds.Y,
                        0, 0,
                        bmp.Size,
                        CopyPixelOperation.SourceCopy);

                    if (!Directory.Exists(ScreenShotDirectory))
                    {
                        Directory.CreateDirectory(ScreenShotDirectory);
                    }

                    if (Directory.Exists(ScreenShotDirectory))
                    {
                        if (String.IsNullOrWhiteSpace(image_path))
                            path = Path.Combine(ScreenShotDirectory, string.Format("{0}.png", DateTime.Now.Ticks));
                        else
                            path = image_path;

                        bmp.Save(path, ImageFormat.Png);
                    }
                }
            }

            return path;
        }
    }
}<commit_msg>capture exceptions thrown by ScreenCapture and log error<commit_after>﻿namespace phoenix
{
    using System;
    using System.IO;
    using System.Drawing;
    using System.Windows.Forms;
    using System.Drawing.Imaging;

    class ScreenCapture
    {
        public static string ScreenShotDirectory
        {
            get { return Path.Combine(Program.Directory, "captures"); }
        }

        public static string TakeScreenShot(string image_path = "")
        {
            string path = string.Empty;

            try
            {
                using (Bitmap bmp = new Bitmap(
                    Screen.PrimaryScreen.Bounds.Width,
                    Screen.PrimaryScreen.Bounds.Height))
                {
                    using (Graphics graphics = Graphics.FromImage(bmp))
                    {
                        graphics.CopyFromScreen(
                            Screen.PrimaryScreen.Bounds.X,
                            Screen.PrimaryScreen.Bounds.Y,
                            0, 0,
                            bmp.Size,
                            CopyPixelOperation.SourceCopy);

                        if (!Directory.Exists(ScreenShotDirectory))
                            Directory.CreateDirectory(ScreenShotDirectory);

                        if (String.IsNullOrWhiteSpace(image_path))
                            path = Path.Combine(ScreenShotDirectory,
                                string.Format("{0}.png", DateTime.Now.Ticks));
                        else
                            path = image_path;

                        bmp.Save(path, ImageFormat.Png);
                    }
                }
            }
            catch
            {
                path = string.Empty;
                Logger.Error("Capturing screen shot failed.");
            }

            return path;
        }
    }
}
{'fraction_non_alphanumeric': 0.07439198855507868, 'fraction_numerical': 0.0017167381974248926, 'mean_word_length': 1.0959232613908874, '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': '5866937', 'n_tokens_mistral': 823, 'n_tokens_neox': 764, 'n_words': 144}