{"record":{"id":"79bc07ce9c132aca","repo":"dotnet/reactive","slug":"value-cannot-be-null-parameter-handlers","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'handlers')","messagePattern":"Value cannot be null\\. \\(Parameter 'handlers'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"AsyncRx.NET/System.Reactive.Async/Linq/Operators/Catch.cs","lineNumber":188,"sourceCode":"                observer.OnNextAsync,\n                async ex =>\n                {\n                    var secondSubscription = await second.SubscribeSafeAsync(observer).ConfigureAwait(false);\n\n                    await subscription.AssignAsync(secondSubscription).ConfigureAwait(false);\n                },\n                observer.OnCompletedAsync\n            );\n\n            return (sink, subscription);\n        }\n\n        public static (IAsyncObserver<TSource>, IAsyncDisposable) Catch<TSource>(IAsyncObserver<TSource> observer, IEnumerator<IAsyncObservable<TSource>> handlers)\n        {\n            if (observer == null)\n                throw new ArgumentNullException(nameof(observer));\n            if (handlers == null)\n                throw new ArgumentNullException(nameof(handlers));\n\n            var innerSubscription = new SerialAsyncDisposable();\n\n            IAsyncObserver<TSource> GetSink() =>\n                Create<TSource>(\n                    observer.OnNextAsync,\n                    async ex =>\n                    {\n                        var handler = default(IAsyncObservable<TSource>);\n\n                        try\n                        {\n                            if (handlers.MoveNext())\n                            {\n                                handler = handlers.Current;\n                            }\n                        }\n                        catch (Exception err)","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/AsyncRx.NET/System.Reactive.Async/Linq/Operators/Catch.cs#L170-L206","documentation":"AsyncObserver.Catch<TSource>(observer, IEnumerator<IAsyncObservable<TSource>> handlers) requires an enumerator of fallback observables to try in sequence when errors occur. A null enumerator leaves no fallback sequence, so ArgumentNullException('handlers') is thrown after the observer check.","triggerScenarios":"Passing null instead of an IEnumerator — e.g. calling handlers.GetEnumerator() on a null collection, or forwarding a nullable enumerator parameter from a caller.","commonSituations":"Retry lists read from configuration that can be empty/null, so GetEnumerator() is invoked on a null sequence.","solutions":["Ensure the source collection is non-null before calling GetEnumerator()","Coalesce: (handlers ?? Enumerable.Empty<IAsyncObservable<int>>()).GetEnumerator()","Fix the config/loader that produced the null handler list"],"exampleFix":"// before\nvar (sink, disp) = AsyncObserver.Catch<int>(observer, configuredHandlers.GetEnumerator()); // configuredHandlers null\n// after\nvar handlers = configuredHandlers ?? Enumerable.Empty<IAsyncObservable<int>>();\nvar (sink, disp) = AsyncObserver.Catch<int>(observer, handlers.GetEnumerator());","handlingStrategy":"validation","validationCode":"if (observer is null) throw new ArgumentNullException(nameof(observer));\nif (handlers is null) throw new ArgumentNullException(nameof(handlers));","typeGuard":"bool HasHandlerList<T>(IEnumerator<IAsyncObservable<T>> handlers) => handlers != null;","tryCatchPattern":"try { var (sink, d) = AsyncObserver.Catch<T>(observer, handlers); } catch (ArgumentNullException ex) when (ex.ParamName == \"handlers\") { /* enumerate a non-null collection */ }","preventionTips":["Never call GetEnumerator() on a possibly-null collection; coalesce first","Treat empty handler lists as valid (observer completes on error)","Load fallback lists with non-null defaults"],"tags":["argument-null","enumerator","rx"],"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"}