using System;

namespace Quadarax.Foundation.Core.Exceptions
{
    public static class ExceptionExc
    {
        public static int GetCode(this Exception e)
        {
            if (!e.Data.Contains("Code"))
                return -1;

            return int.Parse(e.Data["Code"]?.ToString() ?? "-1");
        }

        public static void SetCode(this Exception e, int code)
        {
            e.Data.Add("Code", code);
        }
    }
}
