{"record":{"id":"393941ce4f2290c9","repo":"stride3d/stride","slug":"an-error-occurred-while-removing-an-item-to-the-node-see-the-393941","errorCode":null,"errorMessage":"An error occurred while removing an item to the node, see the inner exception for more information.","messagePattern":"An error occurred while removing an item to the node, see the inner exception for more information\\.","errorType":"exception","errorClass":"NodePresenterException","httpStatus":null,"severity":"error","filePath":"sources/presentation/Stride.Core.Presentation.Quantum/Presenters/MemberNodePresenter.cs","lineNumber":135,"sourceCode":"        }\n        catch (Exception e)\n        {\n            throw new NodePresenterException(\"An error occurred while adding an item to the node, see the inner exception for more information.\", e);\n        }\n    }\n\n    public override void RemoveItem(object value, NodeIndex index)\n    {\n        if (Member.Target == null || !Member.Target.IsEnumerable)\n            throw new NodePresenterException($\"{nameof(MemberNodePresenter)}.{nameof(RemoveItem)} cannot be invoked on members that are not collection.\");\n\n        try\n        {\n            Member.Target.Remove(value, index);\n        }\n        catch (Exception e)\n        {\n            throw new NodePresenterException(\"An error occurred while removing an item to the node, see the inner exception for more information.\", e);\n        }\n    }\n\n    public override NodeAccessor GetNodeAccessor()\n    {\n        return new NodeAccessor(Member, NodeIndex.Empty);\n    }\n\n    private void OnMemberChanging(object? sender, MemberNodeChangeEventArgs e)\n    {\n        RaiseValueChanging(Value);\n        if (Member.Target != null)\n        {\n            Member.Target.ItemChanging -= OnItemChanging;\n            Member.Target.ItemChanged -= OnItemChanged;\n        }\n    }\n","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Presentation.Quantum/Presenters/MemberNodePresenter.cs#L117-L153","documentation":"MemberNodePresenter.RemoveItem wraps the underlying node's Remove operation and rethrows any failure as a NodePresenterException with the original exception as InnerException. It signals that removing an item from the member node failed. Diagnose via the inner exception.","triggerScenarios":"Calling MemberNodePresenter.RemoveItem(value, index) when Member.Target.Remove(value, index) throws — e.g. item not present, read-only collection, or the underlying model rejects the mutation.","commonSituations":"Deleting a list entry in the property grid whose backing collection is read-only or fixed-size; stale UI reference after the model was replaced; removal of an item already removed elsewhere.","solutions":["Read the InnerException to identify the underlying failure.","Confirm the value/index still exists in the target collection before removal.","Check that the target collection is not read-only or fixed-size.","Refresh/rebuild the node presenter if the underlying model was replaced."],"exampleFix":"// before\nnodePresenter.RemoveItem(item, index); // throws if collection is read-only\n// after\nif (nodePresenter.Member.Target is IEnumerable && !(nodePresenter.Member.Target is System.Collections.IList list && list.IsReadOnly))\n    nodePresenter.RemoveItem(item, index);","handlingStrategy":"try-catch","validationCode":"if (nodePresenter?.Member?.Target == null || !nodePresenter.Member.Target.IsEnumerable)\n    throw new InvalidOperationException(\"Target node is not enumerable; RemoveItem will fail.\");","typeGuard":"static bool CanRemoveItem(MemberNodePresenter p, object value) =>\n    p?.Member?.Target != null && p.Member.Target.IsEnumerable && value != null;","tryCatchPattern":"try\n{\n    nodePresenter.RemoveItem(value, index);\n}\ncatch (NodePresenterException ex)\n{\n    logger.Error(ex.InnerException, \"RemoveItem failed on member node\");\n}","preventionTips":["Confirm the item exists in the collection before removal.","Check the backing collection is not read-only/fixed-size.","Refresh presenters when the underlying model instance is replaced."],"tags":["dotnet","node-presenter","collection","wrapped-exception"],"backgroundTag":"wrapped-exception-remove-item-failed","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}