{"record":{"id":"3148498f47fba528","repo":"dotnet/reactive","slug":"value-cannot-be-null-parameter-sources-onerrorresumenext","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'sources')","messagePattern":"Value cannot be null\\. \\(Parameter 'sources'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Ix.NET/Source/System.Interactive/System/Linq/Operators/OnErrorResumeNext.cs","lineNumber":38,"sourceCode":"            if (first == null)\n                throw new ArgumentNullException(nameof(first));\n            if (second == null)\n                throw new ArgumentNullException(nameof(second));\n\n            return OnErrorResumeNextCore(new[] { first, second });\n        }\n\n        /// <summary>\n        /// Creates a sequence that concatenates the given sequences, regardless of whether an error occurs in any of the\n        /// sequences.\n        /// </summary>\n        /// <typeparam name=\"TSource\">Source sequence element type.</typeparam>\n        /// <param name=\"sources\">Source sequences.</param>\n        /// <returns>Sequence concatenating the elements of the given sequences, ignoring errors.</returns>\n        public static IEnumerable<TSource> OnErrorResumeNext<TSource>(params IEnumerable<TSource>[] sources)\n        {\n            if (sources == null)\n                throw new ArgumentNullException(nameof(sources));\n\n            return OnErrorResumeNextCore(sources);\n        }\n\n        /// <summary>\n        /// Creates a sequence that concatenates the given sequences, regardless of whether an error occurs in any of the\n        /// sequences.\n        /// </summary>\n        /// <typeparam name=\"TSource\">Source sequence element type.</typeparam>\n        /// <param name=\"sources\">Source sequences.</param>\n        /// <returns>Sequence concatenating the elements of the given sequences, ignoring errors.</returns>\n        public static IEnumerable<TSource> OnErrorResumeNext<TSource>(this IEnumerable<IEnumerable<TSource>> sources)\n        {\n            if (sources == null)\n                throw new ArgumentNullException(nameof(sources));\n\n            return OnErrorResumeNextCore(sources);\n        }","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/Ix.NET/Source/System.Interactive/System/Linq/Operators/OnErrorResumeNext.cs#L20-L56","documentation":"The params overload OnErrorResumeNext(params IEnumerable<TSource>[] sources) throws ArgumentNullException when the sources array itself is null. This is eager argument validation so failure occurs at call time, not during enumeration.","triggerScenarios":"Calling OnErrorResumeNext((IEnumerable<int>[])null) or passing a null array variable into the params overload.","commonSituations":"Building an array of sequences dynamically (e.g. from a collection of tasks or files) where the array was never initialized.","solutions":["Pass an initialized array; use an empty array if there are no sequences.","Coalesce with a fallback: sources ?? new IEnumerable<int>[0].","Fix the upstream builder that produced a null array."],"exampleFix":"// before\nvar combined = xs.OnErrorResumeNext(seqArray); // seqArray may be null\n// after\nvar combined = xs.OnErrorResumeNext(seqArray ?? new IEnumerable<int>[0]);","handlingStrategy":"validation","validationCode":"if (sources == null) sources = Array.Empty<IEnumerable<int>>();\nvar combined = xs.OnErrorResumeNext(sources);","typeGuard":"static bool HasSources(IEnumerable<int>[]? sources) => sources is { Length: > 0 };","tryCatchPattern":"try\n{\n    var combined = xs.OnErrorResumeNext(sources);\n}\ncatch (ArgumentNullException ex) when (ex.ParamName == \"sources\")\n{\n    // handle missing array\n}","preventionTips":["Initialize sequence arrays with Array.Empty<T>() instead of leaving them null.","Prefer the IEnumerable<IEnumerable<T>> overload with an empty sequence over params with null.","Validate dynamically-built arrays before passing them on."],"tags":["null-reference","argument-validation","linq"],"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"}