// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information. 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace System.Linq
{
    public static partial class EnumerableEx
    {
        /// 
        ///     Returns a sequence that throws an exception upon enumeration.
        /// 
        /// Result sequence element type.
        /// Exception to throw upon enumerating the resulting sequence.
        /// Sequence that throws the specified exception upon enumeration.
        public static IEnumerable Throw(Exception exception)
        {
            if (exception == null)
                throw new ArgumentNullException(nameof(exception));
            return Throw_(exception);
        }
        private static IEnumerable Throw_(Exception exception)
        {
            throw exception;
#pragma warning disable 0162
            yield break;
#pragma warning restore 0162
        }
    }
}