using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace XF.Domain.Exceptions
{
    public class UserFriendlyException : Exception
    {
        public int Code { get; set; }
        public string? FriendlyMessage { get; set; }

        public UserFriendlyException()
        {
            Code = 500;
        }

        public UserFriendlyException(string error) : base(error)
        {
            Code = 500;
        }

        public UserFriendlyException(int code, string error) : base(error)
        {
            Code = code;
        }

        public UserFriendlyException(int code, string error, Exception inner) : base(error, inner)
        {
            Code = code;
        }

        public UserFriendlyException(string error, string friendlyMessage) : base(error)
        {
            Code = 500;
            FriendlyMessage = friendlyMessage;
        }

        public UserFriendlyException(int code, string error, string friendlyMessage) : base(error)
        {
            Code = code;
            FriendlyMessage = friendlyMessage;
        }

        public UserFriendlyException(int code, string error, string friendlyMessage, Exception inner) : base(error, inner)
        {
            Code = code;
            FriendlyMessage = friendlyMessage;
        }

        public static UserFriendlyException SameMessage(string error) => new(error, error);

        protected UserFriendlyException(
            SerializationInfo info,
            StreamingContext context) : base(info, context)
        {
        }
    }
}
