using ZelWiki.Engine.Library.Interfaces;
using ZelWiki.Repository;

namespace ZelWiki.Engine.Implementation
{
    /// <summary>
    /// 异常处理.
    /// </summary>
    public class ExceptionHandler : IExceptionHandler
    {
        /// <summary>
        /// 日志处理
        /// </summary>
        /// <param name="state"></param>
        /// <param name="ex"></param>
        /// <param name="customText"></param>
        public void Log(IZelEngineState state, Exception? ex, string customText)
        {
            if (ex != null)
            {
                ExceptionRepository.InsertException(ex, customText);
            }

            ExceptionRepository.InsertException(customText);
        }
    }
}