{"record":{"id":"7f74231c943c4a8f","repo":"louthy/language-ext","slug":"notsupportedexception","errorCode":null,"errorMessage":"NotSupportedException","messagePattern":"NotSupportedException","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"LanguageExt.Core/Immutable Collections/Seq/DSL/SeqConcat.cs","lineNumber":110,"sourceCode":"            throw Exceptions.SequenceEmpty;\n        }\n    }\n\n    public int Count => \n        ms.Sum(s => s.Count);\n\n    public SeqConcat<A> AddSeq(ISeqInternal<A> ma) =>\n        new (ms.Add(ma));\n\n    public SeqConcat<A> AddSeqRange(Seq<ISeqInternal<A>> ma) =>\n        new (ms.Concat(ma));\n\n    public SeqConcat<A> ConsSeq(ISeqInternal<A> ma) =>\n        new (ma.Cons(ms));\n\n    public ISeqInternal<A> Add(A value)\n    {\n        var last = ms.Last.ValueUnsafe()?.Add(value) ?? throw new NotSupportedException();\n        return new SeqConcat<A>(ms.Take(ms.Count - 1).Add(last));\n    }\n\n    public ISeqInternal<A> Cons(A value)\n    {\n        var head = ms.Head.ValueUnsafe()?.Cons(value) ?? throw new NotSupportedException();\n        return new SeqConcat<A>(head.Cons(ms.Skip(1)));\n    }\n\n    public bool Exists(Func<A, bool> f) =>\n        ms.Exists(s => s.Exists(f));\n        \n    public S Fold<S>(S state, Func<S, A, S> f) =>\n        ms.Fold(state, (s, x) => x.Fold(s, f));\n\n    public S FoldBack<S>(S state, Func<S, A, S> f) =>\n        ms.FoldBack(state, (s, x) => x.FoldBack(s, f));\n","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/louthy/language-ext/blob/2f0e3628242889774d4141960a35671a0280051f/LanguageExt.Core/Immutable Collections/Seq/DSL/SeqConcat.cs#L92-L128","documentation":"SeqConcat.Add appends a value to the LAST segment; if the segment list is empty (or its last segment is null) there is nowhere to add, so it throws NotSupportedException. This DSL node only supports Add when it contains at least one segment.","triggerScenarios":"Calling Add (via seq insertion APIs) on a SeqConcat whose ms segment list is empty — e.g. after constructing it with an empty sequence of segments.","commonSituations":"Custom Seq-building code that creates a SeqConcat without an initial non-empty segment; incremental building that started from an empty concat node.","solutions":["Ensure the SeqConcat is initialized with a non-empty segment (e.g. a SeqStrict) before Add","Use Cons to start a new value at the head instead, or rebuild the seq from scratch","Update LanguageExt — newer versions hardened the internal seq DSL"],"exampleFix":"// before\nvar concat = new SeqConcat<A>(SeqEmptyInternal.Default);\nconcat.Add(value); // NotSupportedException\n// after\nvar concat = new SeqConcat<A>(new SeqStrict<A>(value, SeqEmptyInternal.Default));\nvar next = concat.Add(value); // OK","handlingStrategy":"validation","validationCode":"if (seq.IsEmpty) seq = Seq(value); else seq = seq.Add(value); // public-level equivalent guard","typeGuard":null,"tryCatchPattern":"try { seq = concat.Add(value); }\ncatch (NotSupportedException)\n{ seq = new SeqStrict<A>(value, SeqEmptyInternal.Default); }","preventionTips":["Seed concat nodes with a non-empty segment before mutating","Build sequences with public Seq APIs instead of the DSL internals","Pin/upgrade LanguageExt versions consciously when using internals"],"tags":["csharp","languageext","seq","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"2f0e3628242889774d4141960a35671a0280051f","analyzedAt":"2026-09-15T03:31:55.716Z","contentChangedAt":"2026-09-15T03:31:55.716Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}