using System;

namespace Volpe.Cafe.Reporting
{
    [Serializable]
    internal static class ThrowHelper
    {
        /// <summary>
        /// Checks if the <see cref="Reporter"/> is disposed, and throws an <see cref="ObjectDisposedException"/> if it
        /// was.
        /// </summary>
        public static void ThrowIfDisposed(this IReporter reporter)
        {
            if (reporter.IsDisposed) {
                ReporterDisposed();
            }
        }

        /// <summary>
        /// Throws: ObjectDisposedException("The reporter object is disposed.")
        /// </summary>
        internal static void ReporterDisposed()
        {
            throw new ObjectDisposedException(null, "The reporter object is disposed.");
        }

        /// <summary>
        /// Throws: ArgumentOutOfRangeException(paramName, "Reporting level may not be \"Disabled\".")
        /// </summary>
        internal static void InvalidReportingLevel(string paramName)
        {
            throw new ArgumentOutOfRangeException(paramName, "Reporting level may not be \"Disabled\".");
        }

        /// <summary>
        /// Throws: ArgumentNullException(paramName, "Report path may not be null.")
        /// </summary>
        internal static void ReportPathIsNull(string paramName)
        {
            throw new ArgumentNullException(paramName, "Report path may not be null.");
        }

        /// <summary>
        /// Throws: ArgumentException(paramName, "Report path may not be an empty.")
        /// </summary>
        internal static void ReportPathIsEmpty(string paramName)
        {
            throw new ArgumentException("Report path may not be an empty.", paramName);
        }

    }
}
