Skip to content

Commit

Permalink
Avoid throwing when reading nested metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
glopesdev committed Jul 8, 2024
1 parent a8bccde commit 7fd1893
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions Bonsai.Core/WorkflowBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -905,12 +905,23 @@ static void WriteXmlAttributes(
reader.GetAttribute(nameof(IncludeWorkflowBuilder.Path)) is string path &&
visitedWorkflows.Add(path))
{
var embeddedResource = IncludeWorkflowBuilder.IsEmbeddedResourcePath(path);
using var workflowStream = IncludeWorkflowBuilder.GetWorkflowStream(path, embeddedResource);
using var workflowReader = XmlReader.Create(workflowStream, null, path);
workflowReader.MoveToContent();
var nestedMetadata = ReadMetadata(workflowReader, visitedWorkflows);
types.UnionWith(nestedMetadata.Types);
// we don't want to fail in most cases while reading nested metadata, as this
// is an optional performance optimization and we would lose the visual context
// as to where exactly in the workflow the failure is happening
try
{
var embeddedResource = IncludeWorkflowBuilder.IsEmbeddedResourcePath(path);
using var workflowStream = IncludeWorkflowBuilder.GetWorkflowStream(path, embeddedResource);
using var workflowReader = XmlReader.Create(workflowStream, null, path);
workflowReader.MoveToContent();
var nestedMetadata = ReadMetadata(workflowReader, visitedWorkflows);
types.UnionWith(nestedMetadata.Types);
}
catch (IOException) { }
catch (XmlException) { }
catch (BadImageFormatException) { }
catch (InvalidOperationException) { }
catch (UnauthorizedAccessException) { }
}
}

Expand Down

0 comments on commit 7fd1893

Please sign in to comment.