using System;
using System.Threading;
using System.Windows.Forms;

namespace QC.QsprShared.Dialogs;

public class ExceptionDialog
{
	private Exception qException = new Exception("No Exception");

	public ExceptionDialog(Exception ex)
	{
		qException = ex;
	}

	public void Show()
	{
		Thread thread = new Thread(ShowDialog);
		thread.SetApartmentState(ApartmentState.STA);
		thread.Start();
		thread.Join();
	}

	private void ShowDialog()
	{
		string text = qException.Message + Environment.NewLine;
		if (qException.InnerException != null)
		{
			if (qException.InnerException.Message != null)
			{
				string text2 = text;
				text = text2 + Environment.NewLine + "InnerException:" + Environment.NewLine + qException.InnerException.Message + Environment.NewLine;
			}
			if (qException.InnerException.StackTrace != null)
			{
				string text3 = text;
				text = text3 + Environment.NewLine + "StackTrace:" + Environment.NewLine + qException.InnerException.StackTrace;
			}
		}
		MessageBox.Show(null, text, "QSPR - Message Center", MessageBoxButtons.OK, MessageBoxIcon.Hand);
	}
}
