using System;
using System.Diagnostics;
using System.Xml.Serialization;

namespace QC.QSPRLogSchema;

[Serializable]
[XmlType(AnonymousType = true)]
public class ErrorCode
{
	[DebuggerBrowsable(DebuggerBrowsableState.Never)]
	private string errField;

	[DebuggerBrowsable(DebuggerBrowsableState.Never)]
	private string subErrField;

	[DebuggerBrowsable(DebuggerBrowsableState.Never)]
	private string descField;

	[XmlAttribute("Err")]
	public string Error
	{
		get
		{
			return errField;
		}
		set
		{
			errField = value;
		}
	}

	[XmlAttribute("SubErr")]
	public string SubError
	{
		get
		{
			return subErrField;
		}
		set
		{
			subErrField = value;
		}
	}

	[XmlAttribute("Desc")]
	public string Description
	{
		get
		{
			return descField;
		}
		set
		{
			descField = value;
		}
	}

	public bool ShouldSerializeError()
	{
		return !string.IsNullOrEmpty(Error);
	}

	public bool ShouldSerializeSubError()
	{
		return !string.IsNullOrEmpty(SubError);
	}

	public bool ShouldSerializeDescription()
	{
		return !string.IsNullOrEmpty(Description);
	}

	public ErrorCode()
	{
		errField = string.Empty;
		subErrField = string.Empty;
		descField = string.Empty;
	}

	public ErrorCode(string err = null, string subErr = null, string desc = null)
	{
		if (!string.IsNullOrEmpty(err))
		{
			errField = err;
		}
		else
		{
			errField = string.Empty;
		}
		if (!string.IsNullOrEmpty(subErr))
		{
			subErrField = subErr;
		}
		else
		{
			subErrField = string.Empty;
		}
		if (!string.IsNullOrEmpty(desc))
		{
			descField = desc;
		}
		else
		{
			descField = string.Empty;
		}
	}
}
