stride3d/stride · error · NodePresenterException

An error occurred while adding an item to the node, see the…

Error message

An error occurred while adding an item to the node, see the inner exception for more information.

What it means

RootNodePresenter's nested NodeAccessor AddItem wraps RootNode.Add(value) and rethrows failures as NodePresenterException with the inner exception preserved. It means adding an item directly to the root node failed. The root cause is in the InnerException.

Solutions

  1. Check the InnerException for the true failure.
  2. Ensure the root node (RootNode) is enumerable and its type supports Add.
  3. Ensure the added value matches the root collection's element type.
  4. Use AddItem(value, index) only on enumerable root nodes.

Example fix

// before
accessor.AddItem(newValue, NodeIndex.Empty); // throws if root is not a collection
// after
if (rootNode.IsEnumerable)
    accessor.AddItem(newValue, NodeIndex.Empty);
Defensive patterns

Strategy: try-catch

Validate before calling

if (rootNode == null || !rootNode.IsEnumerable)
    throw new InvalidOperationException("Root node is not enumerable; AddItem will fail.");

Type guard

static bool CanAddToRoot(RootNodePresenter p) => p != null && p.RootNode?.IsEnumerable == true;

Try / catch

try
{
    accessor.AddItem(value, index);
}
catch (NodePresenterException ex)
{
    logger.Error(ex.InnerException, "AddItem failed on root node");
}

Prevention

When it happens

Trigger: Calling AddItem on the root node's accessor when RootNode.Add(value) throws — e.g. the root object is not actually a collection, or the Add on the root collection throws.

Common situations: Attempting to append to a root object that is not enumerable or whose collection implementation rejects the value; misuse of RootNodePresenter against a non-collection root.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/5ce3dcef671eaccd. Report an issue: GitHub.

Appendix: source

Thrown at sources/presentation/Stride.Core.Presentation.Quantum/Presenters/RootNodePresenter.cs:70

        }

        public override void UpdateValue(object newValue)
        {
            throw new NodePresenterException($"A {nameof(RootNodePresenter)} cannot have its own value updated.");
        }

        public override void AddItem(object value)
        {
            if (!RootNode.IsEnumerable)
                throw new NodePresenterException($"{nameof(RootNodePresenter)}.{nameof(AddItem)} cannot be invoked on objects that are not collection.");

            try
            {
                RootNode.Add(value);
            }
            catch (Exception e)
            {
                throw new NodePresenterException("An error occurred while adding an item to the node, see the inner exception for more information.", e);
            }
        }

        public override void AddItem(object value, NodeIndex index)
        {
            if (!RootNode.IsEnumerable)
                throw new NodePresenterException($"{nameof(RootNodePresenter)}.{nameof(AddItem)} cannot be invoked on objects that are not collection.");

            try
            {
                RootNode.Add(value, index);
            }
            catch (Exception e)
            {
                throw new NodePresenterException("An error occurred while adding an item to the node, see the inner exception for more information.", e);
            }
        }

View on GitHub (pinned to 96fad776d2)