Skip to content

Commit

Permalink
Possible unhandled exception trying to extract description for PSCall…
Browse files Browse the repository at this point in the history
… operation that references a script in a pipeline raft. Closes #82
  • Loading branch information
gdivis committed Apr 14, 2020
1 parent 48738d0 commit 90be1dc
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions Windows/InedoExtension/PowerShell/PowerShellScriptInfo.Parse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,25 +100,32 @@ public static PowerShellScriptInfo Parse(TextReader scriptText)

public static async Task<PowerShellScriptInfo> TryLoadAsync(LooselyQualifiedName scriptName)
{
using (var raft = RaftRepository.OpenRaft(scriptName.Namespace ?? RaftRepository.DefaultName))
try
{
if (raft == null)
return null;

using (var item = await raft.OpenRaftItemAsync(RaftItemType.Script, scriptName.Name + ".ps1", FileMode.Open, FileAccess.Read).ConfigureAwait(false))
using (var raft = RaftRepository.OpenRaft(scriptName.Namespace ?? RaftRepository.DefaultName))
{
if (item == null)
if (raft == null)
return null;

using (var reader = new StreamReader(item, InedoLib.UTF8Encoding))
using (var item = await raft.OpenRaftItemAsync(RaftItemType.Script, scriptName.Name + ".ps1", FileMode.Open, FileAccess.Read).ConfigureAwait(false))
{
if (!TryParse(reader, out var info))
if (item == null)
return null;

return info;
using (var reader = new StreamReader(item, InedoLib.UTF8Encoding))
{
if (!TryParse(reader, out var info))
return null;

return info;
}
}
}
}
catch
{
return null;
}
}

private static IEnumerable<ParamInfo> ScrapeParameters(IEnumerable<PSToken> tokens)
Expand Down

0 comments on commit 90be1dc

Please sign in to comment.