Skip to content

Commit

Permalink
Avoid NRE in install-from-ckan (fixes #2171)
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Dec 5, 2017
1 parent 81d3f1a commit 6702d9a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 10 additions & 1 deletion Cmdline/Action/Install.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,16 @@ public int RunCommand(CKAN.KSP ksp, object raw_options)
}

// Parse the JSON file.
options.modules.Add(LoadCkanFromFile(ksp, filename).identifier);
try
{
options.modules.Add(LoadCkanFromFile(ksp, filename).identifier);
}
catch (Kraken kraken)
{
user.RaiseError(kraken.InnerException == null
? kraken.Message
: $"{kraken.Message}: {kraken.InnerException.Message}");
}
}

// At times RunCommand() calls itself recursively - in this case we do
Expand Down
4 changes: 3 additions & 1 deletion GUI/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,9 @@ private void installFromckanToolStripMenuItem_Click(object sender, EventArgs e)
}
catch (Kraken kraken)
{
currentUser.RaiseError(kraken.Message + ": " + kraken.InnerException.Message);
currentUser.RaiseError(kraken.InnerException == null
? kraken.Message
: $"{kraken.Message}: {kraken.InnerException.Message}");
return;
}
catch (Exception ex)
Expand Down

0 comments on commit 6702d9a

Please sign in to comment.