{"record":{"id":"9ec5bd26ca238a95","repo":"dotnet/reactive","slug":"value-cannot-be-null-parameter-sources-9ec5bd","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'sources')","messagePattern":"Value cannot be null\\. \\(Parameter 'sources'\\)","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Ix.NET/Source/System.Interactive/System/Linq/Operators/Catch.cs","lineNumber":40,"sourceCode":"        {\n            if (source == null)\n                throw new ArgumentNullException(nameof(source));\n            if (handler == null)\n                throw new ArgumentNullException(nameof(handler));\n\n            return CatchCore(source, handler);\n        }\n\n        /// <summary>\n        /// Creates a sequence by concatenating source sequences until a source sequence completes successfully.\n        /// </summary>\n        /// <typeparam name=\"TSource\">Source sequence element type.</typeparam>\n        /// <param name=\"sources\">Source sequences.</param>\n        /// <returns>Sequence that continues to concatenate source sequences while errors occur.</returns>\n        public static IEnumerable<TSource> Catch<TSource>(this IEnumerable<IEnumerable<TSource>> sources)\n        {\n            if (sources == null)\n                throw new ArgumentNullException(nameof(sources));\n\n            return CatchCore(sources);\n        }\n\n        /// <summary>\n        /// Creates a sequence by concatenating source sequences until a source sequence completes successfully.\n        /// </summary>\n        /// <typeparam name=\"TSource\">Source sequence element type.</typeparam>\n        /// <param name=\"sources\">Source sequences.</param>\n        /// <returns>Sequence that continues to concatenate source sequences while errors occur.</returns>\n        public static IEnumerable<TSource> Catch<TSource>(params IEnumerable<TSource>[] sources)\n        {\n            if (sources == null)\n                throw new ArgumentNullException(nameof(sources));\n\n            return CatchCore(sources);\n        }\n","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/Ix.NET/Source/System.Interactive/System/Linq/Operators/Catch.cs#L22-L58","documentation":"The Catch overload taking a sequence of sequences, Catch<TSource>(IEnumerable<IEnumerable<TSource>> sources), throws ArgumentNullException with parameter name 'sources' when the outer sequence is null. The library requires a (possibly empty) container of sequences; null is rejected eagerly at call time.","triggerScenarios":"Calling Catch<TSource>(sources) with a null outer enumerable, e.g. a list of retry attempts built elsewhere that was never assigned.","commonSituations":"A factory method returning null instead of an empty list; LINQ result of a nullable source without coalescing; deserialization producing null for an empty collection.","solutions":["Pass a non-null enumerable; use an empty sequence if there are no candidates.","Coalesce at the call site: (sources ?? Enumerable.Empty<IEnumerable<T>>()).Catch().","Fix the producer to return Enumerable.Empty<IEnumerable<T>>() instead of null.","Enable nullable reference types to catch it at compile time."],"exampleFix":"// before\nvar result = ((List<IEnumerable<int>>)null).Catch();\n// after\nvar result = (sources ?? Enumerable.Empty<IEnumerable<int>>()).Catch();","handlingStrategy":"validation","validationCode":"if (sources is null)\n    throw new ArgumentNullException(nameof(sources));\n// or coalesce:\nsources ??= Enumerable.Empty<IEnumerable<TSource>>();","typeGuard":"static bool IsUsableSources<TSource>(IEnumerable<IEnumerable<TSource>> s) => s != null;","tryCatchPattern":"try\n{\n    var result = sources.Catch();\n}\ncatch (ArgumentNullException ex) when (ex.ParamName == \"sources\")\n{\n    var result = Enumerable.Empty<TSource>();\n}","preventionTips":["Producers of collections should return empty sequences, never null.","Coalesce nullable outer enumerables before passing to operators.","Enable nullable reference types to catch null arguments at compile time.","Be careful with deserialization: configure it to emit empty collections instead of null."],"tags":["csharp","null-argument","linq","ix-net","argument-validation"],"backgroundTag":"null-argument","analyzedSha":"94b5d5ab912789f5abe9a72138a25bbd716fe59c","analyzedAt":"2026-09-15T02:26:24.759Z","contentChangedAt":"2026-09-15T02:26:24.759Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}