Skip to content

Expose rendering errors (e.g. loggedErr) in a public API #3391

@solyane2002

Description

@solyane2002

Description of new feature

I would like Cytoscape.js to expose rendering-time errors, such as those currently tracked internally via _private.rscratch.loggedErr, through a public and supported API — for example via edge.error()

Motivation for new feature

When using curveStyle: "segments", if the edge has an invalid configuration (e.g., missing segment points or malformed control points), Cytoscape.js internally flags it with loggedErr = true to avoid repeating console warnings.

In my case, I need to return an error and reject the graph properly with a friendly message in the UI.

Here is the function I implemented for now:

export const checkForInvalidEdgeWarning = (cyCore: Core): Error | null => {
  const invalidEdgeIds: string[] = [];
  cyCore.edges('[curveStyle = "segments"]').forEach((edge) => {
    if (edge[0]._private.rscratch.loggedErr) {
      invalidEdgeIds.push(edge.id());
    }
  });

  if (invalidEdgeIds.length > 0) {
    return new Error(`invalid edge(s) detected on segments curve style  (${invalidEdgeIds.join(', ')})`);
  }
  return null;
};

However, this information is only available via a private internal structure (edge._private.rscratch.loggedErr), which:

  • Is not part of the public API and may break across versions
  • Is not safe to use in TypeScript without casting to any
  • Prevents detecting errors programmatically in a clean and maintainable way

Thanks for your great work on Cytoscape.js!
Let me know if you'd consider a PR, or if there's a recommended alternative way to detect such rendering errors.

For reviewers

Reviewers should ensure that the following tasks are carried out for incorporated issues:

  • Ensure that the reporter has adequately described their idea. If not, elicit more information about the use case. You should iteratively build a spec together.
  • Ensure that the issue is a good fit for the core library. Some things are best done in extensions (e.g. UI-related features that aren't style-related). Some things are best done by app authors themselves -- instead of in Cytoscape libraries.
  • The issue has been associated with a corresponding milestone.
  • The commits have been incorporated into the unstable branch via pull request. The corresponding pull request is cross-referenced.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions